I am trying to design an application that would require me to retrieve data stored in blobstore and send it as attachment. Does google app engine allow this? From the documentation, i could not find a way to retrieve data from blobstore for processing within the app.. can someone please tell me how to accomplish this? Code examples and/or pointers to related online resources would be really helpful.
views:
143answers:
3As of now, it seems this isn't possible. You can only cause the the file to be sent to the client.
It's possible you could do what you need using a Datastore Blob?
It's worth also noting that the Blobstore is "experimental" and may change. It's possible additional functionality may be added that would allow what you'r trying to do.
This can be accomplished in two steps using the code from the Complete Sample App. http://code.google.com/appengine/docs/java/blobstore/overview.html#Complete_Sample_App
1) Write a servlet that takes a blobkey and returns the contents of the blob.
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
blobstoreService.serve(blobKey, res);
}
2) Within your application, use the URLFetchService.fetch(java.net.URL url) with the proper blobkey to retrieve the blob (as a stream) and attach it to the email.
You can now read data from the blobstore, using BlobReader, which provides a simple, file-like interface.