Package com.google.appengine.api.blobstore

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


  /**
   * Deletes a Blob from the Blobstore.
   * @param s - the Blob Key of the Blob to delete.
   */
  public static void delete(String s) {
    BlobstoreServiceFactory.getBlobstoreService().delete(new BlobKey(s));
  }
View Full Code Here


  private static Logger log = Logger.getLogger(UploadServlet.class.getName());

  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException {
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
    // Writes the file bytes into the response
    blobstoreService.serve(blobKey, res);
    String filename = BlobstoreUtil.getFilename(blobKey);
    log.info("Serving " + blobKey.getKeyString() + " as " + filename);
    res.setHeader("Content-Disposition","attachment;filename=" + filename);
  }
View Full Code Here

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    GcsFilename fileName = getFileName(req);
    if (SERVE_USING_BLOBSTORE_API) {
      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      BlobKey blobKey = blobstoreService.createGsBlobKey(
          "/gs/" + fileName.getBucketName() + "/" + fileName.getObjectName());
      blobstoreService.serve(blobKey, resp);
    } else {
      GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, BUFFER_SIZE);
      copy(Channels.newInputStream(readChannel), resp.getOutputStream());
View Full Code Here

        gcsFilename, new GcsFileOptions.Builder().mimeType("image/png").build());
    byte[] bytes = BaseEncoding.base64().decode(PNG);
    channel.write(ByteBuffer.wrap(bytes));
    channel.close();

    BlobKey blobKey = BLOB_STORE.createGsBlobKey(
        "/gs/" + gcsFilename.getBucketName() + "/" + gcsFilename.getObjectName());

    byte[] imageData = BLOB_STORE.fetchData(blobKey, 0, bytes.length);
    assertArrayEquals(bytes, imageData);
View Full Code Here

        throw new UnsupportedOperationException(
            String.format("File %s does not have a finalized name", file.getFullPath()));
      }

      if (file.getFileSystem().equals((AppEngineFile.FileSystem.BLOBSTORE))) {
        BlobKey blobKey = getBlobKey(file);
        if (blobKey != null) {
          blobKeys.add(blobKey);
        }
      } else if (file.getFileSystem().equals((AppEngineFile.FileSystem.GS))) {
        blobKeys.add(blobstoreService.createGsBlobKey(file.getFullPath()));
View Full Code Here

      throw new NullPointerException("file is null");
    }
    if (file.getFileSystem() != AppEngineFile.FileSystem.BLOBSTORE) {
      throw new IllegalArgumentException("file is not of type BLOBSTORE");
    }
    BlobKey cached = file.getCachedBlobKey();
    if (null != cached) {
      return cached;
    }
    String namePart = file.getNamePart();
    String creationHandle = (namePart.startsWith(CREATION_HANDLE_PREFIX) ? namePart : null);

    if (null == creationHandle) {
      return new BlobKey(namePart);
    }

    String origNamespace = NamespaceManager.get();
    Query query;
    Entity blobInfoEntity = null;
View Full Code Here

      // Update the photo count of the corresponding submission
      PhotoSubmission photoSubmission = this.getSubmissionById(entry.getSubmissionId());
      photoSubmission.setNumberOfPhotos(photoSubmission.getNumberOfPhotos() - 1);
      this.save(photoSubmission);

      BlobKey blobKey = entry.getBlobKey();
      if (blobKey != null) {
        // Delete the image binary from blob store
        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
        blobstoreService.delete(blobKey);
      }
View Full Code Here

      System.out.println("Received a request to serve a blob with the id: " + req.getParameter("id")
          + ", and file: " + req.getParameter("file"));
      HUDXML3BlobService hxbs = new HUDXML3BlobService();
      HUDXML3Blob b = hxbs.getHUDXML3Blob(req.getParameter("id"));
      int requestedfileNumber = Integer.valueOf(req.getParameter("file"));
      BlobKey blobKey;
      switch (requestedfileNumber) {
          case 1: blobKey = new BlobKey(b.getCsvUrl1());
          break;
          case 2: blobKey = new BlobKey(b.getCsvUrl2());
          break;
          case 3: blobKey = new BlobKey(b.getCsvUrl3());
          break;
          case 4: blobKey = new BlobKey(b.getCsvUrl4());
          break;
          case 6: blobKey = new BlobKey(b.getCsvUrl6());
          break;
          default: blobKey = new BlobKey(b.getCsvUrl1()); }
        //BlobKey blobKey2 = new BlobKey("wWN4LMO8okJ-zlmkdQk8Bg");
      //System.out.println("overriding returned key:" + blobKey.getKeyString() + " with static key: " + blobKey2.getKeyString());
        System.out.println("sending blob key: " + blobKey.getKeyString());
        resp.setContentType("application/x-download");
        BlobInfoFactory bif = new BlobInfoFactory();
        String fileName = bif.loadBlobInfo(blobKey).getFilename();
        resp.setHeader("Content-Disposition", "attachment; filename=" + fileName);
        blobstoreService.serve(blobKey, resp);
View Full Code Here

      long maxPhotoSize = adminConfigDao.getMaxPhotoSize();

      ArrayList<BlobKey> validSubmissionKeys = new ArrayList<BlobKey>();
      for (Entry<String, BlobKey> entry : blobs.entrySet()) {
        BlobKey blobKey = entry.getValue();

        BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
        String contentType = blobInfo.getContentType().toLowerCase();
        long size = blobInfo.getSize();
View Full Code Here

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {   
    log.info("doGet in RosieCSVBlobServlet entered");
    //this needs to change to the GCS key in the future?
    hudXMLURL = new BlobKey(req.getParameter("hud_xml_url"));
    String[] blobStoreURL = new String[5];
    // check the completion state of each of the files by reading from the datastore
        // look at the last/most recent record (either in file or in datastore/cloud sql)
   
    // if file1 already started and not finished, resume file 1
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.