0
votes

I am writing a servlet which will get a blob out of blobstore by referencing the blobkey. I looked online but didn't find any good examples. The google site has following example:

BlobKey key = new BlobKey(blobkey);
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
blobstoreService.serve(key, resp);

So the client knows the blobkey and it sends it to the servlet. The servlet should use the key to get the blob out of blobstore and send it back in a response.

Any suggestions? In java please.

Thanks Sarah

1
The above example is doing exactly that - serving the contents of blob. What seems to be the problem? - Peter Knego

1 Answers

1
votes

If you are trying to read the contents of the blob into your app and do something with it, you should check out BlobstoreInputStream. The code would look something like:

BlobKey key = new BlobKey(blobkey);
InputStream is = new BlobInputStream(key);

You can now read the contents of the blob using any of the read() methods of InputStream.