How to get blob filename from BlobKey on app-engine

天大地大妈咪最大 提交于 2019-12-20 04:22:54

问题


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:


Use the BlobInfo class.

BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
String fileName = blobInfo.getFilename();


来源:https://stackoverflow.com/questions/26574680/how-to-get-blob-filename-from-blobkey-on-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!