Reputation: 499
I have uploaded a file,say a.txt to the Google BlobStore. Using a separate java program, I need to download / write to a.txt. How do I get the BlobKey of a.txt in this second java file so that I can download it using the Serve method?
Upvotes: 0
Views: 1142
Reputation: 1221
yo can get all information about blobstore using following code
Iterator<BlobInfo> iterator = null;
iterator = new BlobInfoFactory().queryBlobInfos();
while (iterator.hasNext()) {
system.out.println(iterator.next().getBlobKey());//You can put condition here whats your file name
system.out.println(iterator.next().getFilename());
}
using this code you will get bob key and than you have to used servlet to send this key and serve blob as following code
String key = request.getparameter("blobkey");
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = new BlobKey(key);
blobstoreService.serve(blobKey, response);
Upvotes: 2