How to get blob filename from BlobKey on app-engin

2019-02-28 20:49发布

This is a server side question. I have a BlobKey and nothing else. How do I get the blob filename from said BlobKey? I know how to get the servingUrl as

ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(blobKey).secureUrl(false);
String servingUrl = ImagesServiceFactory.getImagesService().getServingUrl(options);

But how do I get the filename as saved/shown in Blob Viewer as for instance image_1.png? I am using Java -- not python.

1条回答
太酷不给撩
2楼-- · 2019-02-28 21:30

Use the BlobInfo class.

BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
String fileName = blobInfo.getFilename();
查看更多
登录 后发表回答