Package com.google.appengine.api.blobstore

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


      this.save(photoSubmission);

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

      // Delete the persistent entry record of this image
      pm.deletePersistent(entry);
    } finally {
View Full Code Here


          }

          contentRangeHeader = String.format("bytes %d-%d/%d", previousByte, lastByte,
            photoEntry.getOriginalFileSize());
         
          BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
          bytes = blobstoreService.fetchData(photoEntry.getBlobKey(), previousByte, lastByte);
        } else {
          bytes = dataChunkDao.getBytes(photoEntry.getId(), previousByte);
         
          if (bytes == null) {
            throw new IllegalArgumentException(String.format("PhotoEntry with id '%s' does not "
View Full Code Here

      String latitude = req.getParameter("latitude");
      String longitude = req.getParameter("longitude");

      String date = req.getParameter("date");

      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req);

      BlobInfoFactory blobInfoFactory = new BlobInfoFactory();

      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();

        if (!contentType.startsWith("image/")) {
          blobstoreService.delete(blobKey);
          LOG.warning(String.format("Uploaded file has content type '%s'; skipping.", contentType));
          continue;
        }

        if ((size > maxPhotoSize) || (size == 0)) {
          blobstoreService.delete(blobKey);
          LOG.warning(String.format("Uploaded file is %d bytes; skipping.", size));
          continue;
        }

        validSubmissionKeys.add(blobKey);
View Full Code Here

 
  private void purge(PhotoEntry photoEntry, PersistenceManager pm) {
    try {
      emailUtil.sendPhotoEntryToAdmins(photoEntry);
    } finally {
      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      blobstoreService.delete(photoEntry.getBlobKey());
   
      photoEntry.setBlobKey(null);
      pm.makePersistent(photoEntry);
     
      LOG.info("BlobKey set to null.");
View Full Code Here

      message.setSender(fromAddress);
      message.setTextBody("YouTube Direct was unable to upload a photo submission to Picasa.\n\n"
          + "There might be a service issue, or your Picasa configuration might be incorrect.\n\n"
          + "The photo in question is attached.");

      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      byte[] photoBytes = blobstoreService.fetchData(
          photoEntry.getBlobKey(), 0, photoEntry.getOriginalFileSize() - 1);

      MailService.Attachment photoAttachment =
          new MailService.Attachment(photoEntry.getOriginalFileName(), photoBytes);
      message.setAttachments(photoAttachment);
View Full Code Here

     * @param url
     *            the part of url
     * @return context-relative URL
     */
    public static String blobstoreUrl(String url) {
        BlobstoreService bs = BlobstoreServiceFactory.getBlobstoreService();
        boolean empty = StringUtil.isEmpty(url);
        if (!empty && url.indexOf(':') >= 0) {
            return bs.createUploadUrl(url);
        }
        HttpServletRequest request = request();
        String path =
            (String) request.getAttribute(ControllerConstants.BASE_PATH_KEY);
        if (path == null) {
            path = RequestUtil.getPath(request);
        }
        int pos = path.lastIndexOf('/');
        path = path.substring(0, pos + 1);
        if (empty) {
            return bs.createUploadUrl(path);
        } else if (url.startsWith("/")) {
            return bs.createUploadUrl(url);
        }
        return bs.createUploadUrl(path + url);
    }
View Full Code Here

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        String loginUrl = userService.createLoginURL("/");
        String logoutUrl = userService.createLogoutURL("/");

        BlobstoreService blobstoreService =
                BlobstoreServiceFactory.getBlobstoreService();
        UploadOptions uploadOptions = UploadOptions.Builder
                .withMaxUploadSizeBytesPerBlob(1024L * 1024L * 1024L)
                .maxUploadSizeBytes(10L * 1024L * 1024L * 1024L);
        String uploadUrl = blobstoreService.createUploadUrl("/upload", uploadOptions);

        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
        List<Map<String, Object>> uploads = new ArrayList<Map<String, Object>>();

View Full Code Here

            HttpServletResponse resp)
            throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        BlobstoreService bs =
                BlobstoreServiceFactory.getBlobstoreService();

        String[] uploadKeyStrings = req.getParameterValues("delete");
        List<Key> keysToDelete = new ArrayList<Key>();
        if (uploadKeyStrings != null) {
View Full Code Here

            HttpServletResponse resp)
            throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        BlobstoreService bs =
                BlobstoreServiceFactory.getBlobstoreService();

        String uploadKeyStr = req.getParameter("key");
        Entity userUpload = null;
        BlobKey blobKey = null;
        if (uploadKeyStr != null) {
            try {
                userUpload = ds.get(KeyFactory.stringToKey(uploadKeyStr));
                if (((User)userUpload.getProperty("user")).equals(user)) {
                    blobKey = (BlobKey)userUpload.getProperty("upload");
                }
            } catch (EntityNotFoundException e) {
                // Leave blobKey null.
            }
        }
       
        if (blobKey != null) {
            bs.serve(
                    blobKey,
                    bs.getByteRange(req),
                    resp);
        } else {
            resp.sendError(404);
        }
    }
View Full Code Here

        throws IOException {

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        BlobstoreService bs =
                BlobstoreServiceFactory.getBlobstoreService();
       
        Map<String, List<BlobKey>> blobFields = bs.getUploads(req);
        List<BlobKey> blobKeys = blobFields.get("upload");
        Key userGroupKey = KeyFactory.createKey("UserUploadGroup", user.getEmail());
        for (BlobKey blobKey : blobKeys) {
            Entity userUpload = new Entity("UserUpload", userGroupKey);
            userUpload.setProperty("user", user);
View Full Code Here

TOP

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

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.