简体   繁体   中英

How load and save entire file from blobstore, using only BlobKey?

I want to service file (edit), that user uploaded to server. After saving it to blobstore, I want to load it to memory for editing. After storing file I got BlobKey in return. As I understand, I should use the following method to load it into memory:

byte[] BlobstoreService.fetchData(BlobKey blobKey, long startIndex, long endIndex)

The problem is that I do not know how big the file is, so I do not know what to pass as the endIndex variable. How, having only BlobKey , do I load a file from blobstore, change it, save new version and recive new BlobKey of changed file?

From the javadoc reference , seems like you can load a BlobInfo object that will contain your size. You just need to call

BlobInfoFactory() bif = New BlobInfoFactory();
BlobInfo bi = bif.loadBlobInfo(blobKey);
long size = bi.getSize();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM