Google App Engine Blobstore and Restlet - "Must be called from blob download callback request"

Mistake

Called: java.lang.IllegalStateException: must be called from blob to load the callback request. in com.google.appengine.api.blobstore.BlobstoreServiceImpl.getUploads (BlobstoreServiceImpl.java:169)

the code

public class UserUploadProfilePictureResource extends ServerResource { @Post public void handleBlobstoreUpload(Representation entity) { Representation rep =null; if (entity !=null) { if (MediaType.MULTIPART_FORM_DATA.equals(entity.getMediaType(), true)) { Request restletRequest = getRequest(); HttpServletRequest servletRequest = ServletUtils.getRequest(restletRequest); BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(servletRequest); 

possible solution (but I do not want)

At first. I do not want to call the second HttpServlet.

Secondly. Regarding these messages, there is a solution to manually write the file:

  • how to load a downloaded file in the form of blocks in a servlet using the Google ad mechanism
  • Upload the image to a Google mobile device with Java software

Google says the following:

Deprecated: the file API feature used here to write files to Blobstore will be removed in the future, in favor of writing files to Google Cloud Storage and using Blobstore to serve them.

Possible Solution2 (but only the concept of a workaround)

http://www.cloudave.com/1055/the-new-google-app-engine-blobstore-api-first-thoughts/

Bret Slatkin notes that when the API processes the POST URL used to upload files, it creates a unique one-time URL that mitigates any potential sniffing.

This is ideal for a scenario when you create a web form for user submission. But, it makes things harder if you're trying to provide a REST API that allows you to upload files (think of, for example, TwitPic). In this case, you will have to write your own render that simulates what the web form will do (get the files, create a random POST URL, call it, ...)

Question

What is the best approach for storing images in the google engine? Is there a better way than blobstore? How to save images in a block store?

+7
java google-app-engine file file-upload blobstore
source share
1 answer

I think your best and will be officially supported choice is the Google Cloud Storage Client Library, https://developers.google.com/appengine/docs/java/googlecloudstorageclient/ . It looks like they will not support blobstore programming, perhaps more likely to use cloud storage on top of blobstore. Image and blobstore api works with GCS to create and store blobstore keys and generate url / resizing images, etc.

Another unofficial way that I didn’t look too much is to copy the source of the Api files and save it, probably using rpc calls that will not disappear or will always be available, but I don’t know for sure.

+3
source share

All Articles