Package com.google.appengine.api.blobstore

Examples of com.google.appengine.api.blobstore.BlobKey


   
    BlobKey [] keys = new BlobKey[blobKeyStrs.size()];
   
    int i = 0;
    for (String blobKeyStr : blobKeyStrs) {
      keys[i++] = new BlobKey(blobKeyStr);
    }
   
    blobstore.delete(keys);
  }
View Full Code Here


   *
   * @throws Exception
   */
  @Test
  public void testBlobKey() throws Exception {
    assertEquals(new BlobKey("abcde"),
        parser("blobkey('abcde')").bool_exp().e.evaluate(null).getPayload());
  }
View Full Code Here

    final PreparedQuery pq = datastore.prepare(query);
    final List<Entity> entList = pq.asList(FetchOptions.Builder
        .withLimit(1));
    if (entList.size() > 0) {
      final String blobKeyString = entList.get(0).getKey().getName();
      return new BlobKey(blobKeyString);
    }
    return null;
  }
View Full Code Here

    final String[] parts = request.getPathInfo().split("/");
    final String fileName = parts[1];

    // //////////////

    final BlobKey blobKey = getBlobKeyByFileName(fileName);

    // //////////////

    if (blobKey == null || blobKey.equals("undefined")
        || blobKey.equals("") || blobKey.equals("null")) {
      // return a not found error
      response.setStatus(HttpServletResponse.SC_NOT_FOUND);
      LOGGER.warning("No blob found by filename " + fileName);

    } else {
View Full Code Here

        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        assertThat(" 実行前のメモ数は5", MemoService.list(minutesKey).size(), is(5));
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        assertThat("blobKey が返される", blobKey, is(notNullValue()));
        File file =
            new File("www-test/WEB-INF/appengine-generated/"
                + blobKey.getKeyString());
        assertThat(" ファイルが作成される", file.exists(), is(true));
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String line;
        int index = 0;
        while ((line = reader.readLine()) != null) {
View Full Code Here

            fileService.openWriteChannel(file, true);
        OutputStream output = Channels.newOutputStream(writeChannel);
        output.write(imageBytes);
        output.close();
        writeChannel.closeFinally();
        BlobKey blobKey = fileService.getBlobKey(file);
        // test@example.com というユーザがログイン中、という状態を作っておく。
        TestEnvironment environment =
            (TestEnvironment) ApiProxy.getCurrentEnvironment();
        environment.setEmail("test@example.com");
        int beforeCount = tester.count(Profile.class);
        tester.param("key", blobKey.getKeyString());
        tester.start(PATH);
        assertThat(
            " レスポンスコードが200",
            tester.response.getStatus(),
            is(HttpServletResponse.SC_OK));
View Full Code Here

        Key minutesKey = MinutesService.put(" テスト用議事録");
        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        tester.param("download", blobKey.getKeyString());
        tester.start(PATH);
        assertThat(
            "MinutesController のインスタンスが使用される",
            tester.getController(),
            instanceOf(MinutesController.class));
View Full Code Here

        User currentUser = UserServiceFactory.getUserService().getCurrentUser();
        if (currentUser == null) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            return null;
        }
        BlobKey blobKey = new BlobKey(asString("key"));
        String servingUrl =
            ImagesServiceFactory.getImagesService().getServingUrl(
                blobKey,
                32,
                false);
View Full Code Here

        if (minutes.getAuthor().equals(currentUser) == false) {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return null;
        }
        // TSV 作成と削除をする
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        MinutesService.deleteMinutes(minutes);
        // ダウンロードURL をメールで送信する
        Message message = new Message();
        message.setSender("minutes@yourappid.appspotmail.com");
        message.setSubject(" 議事録[" + minutes.getTitle() + "] がTSV に変換されました");
        message.setTo(currentUser.getEmail());
        StringBuilder b = new StringBuilder();
        b
            .append(request.getScheme())
            .append("://")
            .append(request.getServerName());
        if (request.getServerPort() != 80) {
            b.append(":").append(request.getServerPort());
        }
        b.append("/minutes?download=").append(blobKey.getKeyString());
        message.setTextBody(b.toString());
        MailService mailService = MailServiceFactory.getMailService();
        mailService.send(message);
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
        return null;
View Full Code Here

            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return null;
        }
        BlobstoreService blobstoreService =
            BlobstoreServiceFactory.getBlobstoreService();
        BlobKey blobKey = new BlobKey(blobKeyString);
        BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(blobKey);
        response.setContentType(blobInfo.getContentType());
        response.setContentLength((int) blobInfo.getSize());
        response.setHeader(
            "Content-disposition",
View Full Code Here

TOP

Related Classes of com.google.appengine.api.blobstore.BlobKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.