【问题标题】:referencing a blob via a File object通过 File 对象引用 blob
【发布时间】:2012-08-23 15:54:53
【问题描述】:

有什么方法可以通过 File 对象引用 blobstore 中的 blob 吗?我有 blob 密钥。现在我该如何引用那里的 blob?

// Let the blob key be 'squuheaeinlie'
File blobReference = new File(...?....);

我实际上指的是一个 xml 文件,它是一个 blob。我想读写那个 xml 文件。

【问题讨论】:

    标签: java file google-app-engine blob


    【解决方案1】:

    是的,您可以通过 AppEngineFile 将 blobstore blob 作为文件访问(不是真正的 File,而是关闭)。

    这是一个关于如何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
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-11
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 2011-07-06
    • 2012-07-07
    • 2012-01-05
    相关资源
    最近更新 更多