Hope this helps, this is the way I have been doing it for a while:
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = new BlobKey(KEY);
// Start reading
ByteArrayOutputStream out = new ByteArrayOutputStream();
long inxStart = 0;
long inxEnd = 1024;
boolean flag = false;
do {
try {
byte[] b = blobstoreService.fetchData(blobKey,inxStart,inxEnd);
out.write(b);
if (b.length < 1024)
flag = true;
inxStart = inxEnd + 1;
inxEnd += 1025;
} catch (Exception e) {
flag = true;
}
} while (!flag);
byte[] filebytes = out.toByteArray();
I used to use:
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
filesize = blobInfo.getSize();
to obtaint the size, but for some reason, sometimes this info was null.
Maybe all this can give you an idea.