Google AppEngine Blobstore: Download Blob by filename in Java

Suppose I uploaded a bunch of files (images in this case, if that matters) for the GAE BlobStore.
Later, I want to be able to download these files from another location. I know that I can use the BlobStoreService service method to capture blob from BlobKey, but how do I get the blobkey associated with the given file name?
I don't seem to see the built-in functions for this.

+4
source share
2 answers

BlobInfo metadata containing the file name attribute is stored in __BlobInfo__ only __BlobInfo__ objects in the data warehouse.

 Query query = new Query("__BlobInfo__"); query.addFilter("filename", FilterOperator.EQUAL, filename); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(query); List<Entity> entList = pq.asList(FetchOptions.Builder.withLimit(1)); String name = entList.get(0).getKey().getName(); 
+18
source

You can request BlobInfo objects by file name.

-5
source

Source: https://habr.com/ru/post/1346313/


All Articles