java - 通过 File 对象引用 blob

标签 java file google-app-engine blob

有什么方法可以通过 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/

相关文章:

java - 访问 Websphere 上的 EntityManager 时出现 NullPointerException

java - 通过代码从当前运行的 JAR 中提取文件

javascript - 如何使用 JavaScript 获取文件和文件名?

asp.net - 集成 .NET 应用程序和 Google Apps 的策略

python - 在 Google App Engine 中导入 python 类

java - 从数据库自动填充 struts2 复选框

java - 在 Oozie 中单独处理行

google-app-engine - Google Cloud Datastore 中的 Key 属性类型有何特别之处?

Java:将无符号 8 字节时间戳转换为微秒精确日期

java - Android 应用程序在尝试从文件读取数据时不断崩溃