有什么方法可以通过 File
对象引用 blobstore 中的 blob 吗?我有 blob key 。现在我该如何引用该 blob 呢?
// Let the blob key be 'squuheaeinlie'
File blobReference = new File(...?....);
我实际上指的是一个 xml 文件,它是一个 blob。我想读取和写入该 xml 文件。
最佳答案
是的,您可以通过 AppEngineFile
以文件形式访问 blobstore blob(不是真正的文件
,而是关闭) .
以下是有关如何 write and read blobs via this API. 的完整示例
编辑:您可以通过 blob-key 加载现有的 blob:
FileService fileService = FileServiceFactory.getFileService();
AppEngineFile file = fileService.getBlobFile(blob-key);
FileReadChannel channel = fileService.openReadChannel(file, false);
// now read from channel
关于java - 通过 File 对象引用 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12171154/