【问题标题】:Azure blob storage - Copy Block blobs in the SAME containerAzure Blob 存储 - 在 SAME 容器中复制块 Blob
【发布时间】:2016-09-21 12:27:30
【问题描述】:

我正在使用带有 Android API 的 Azure 存储。我正在尝试将一个块 blob 从一个位置复制到另一个位置(在相同的 blob 容器中)。

但是,当我制作副本时,调用 startCopy 方法后出现“CannotVerifyCopySource”错误。

示例代码:

private void sample(String path1, String path2, File file) {

    CloudBlockBlob blob1 = container.getBlockBlobReference(path1);
    CloudBlockBlob blob2 = container.getBlockBlobReference(path2);

    blob1.upload(new FileInputStream(file), file.length());
    blob1.startCopy(blob2);
}

关于可能是什么问题的任何想法?

最好的问候,

【问题讨论】:

  • 在此处查看有关错误的错误代码详细信息:msdn.microsoft.com/en-us/library/azure/dd179439.aspx,似乎 blob 服务出现问题(500 内部服务器错误)。您能否按照建议捕获更多错误详细信息并在此处分享?
  • 你怎么知道blob1是有效的?上传有用吗?在尝试从blob1 复制到blob2 之前,上传是否完成?
  • 上传完成(我在上传后使用了断点,检查了存储库并且文件在那里,没有抛出异常)。所有这些代码都是同步运行的。在 startCopy 方法中抛出错误。

标签: android azure


【解决方案1】:

请参阅下面关于startCopy 的来源。我认为你应该在这里使用blob2.startCopy(blob1)。

/**
     * Requests the service to start copying a block blob's contents, properties, and metadata to a new block blob.
     *
     * @param sourceBlob
     *            A <code>CloudBlockBlob</code> object that represents the source blob to copy.
     *
     * @return A <code>String</code> which represents the copy ID associated with the copy operation.
     *
     * @throws StorageException
     *             If a storage service error occurred.
     * @throws URISyntaxException
     */
    @DoesServiceRequest
    public final String startCopy(final CloudBlockBlob sourceBlob) throws StorageException, URISyntaxException {
        return this.startCopy(sourceBlob, null /* sourceAccessCondition */,
                null /* destinationAccessCondition */, null /* options */, null /* opContext */);
    }

【讨论】:

    猜你喜欢
    • 2011-02-24
    • 2016-02-12
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    • 2020-01-12
    • 2014-06-03
    • 2020-12-19
    • 2013-02-23
    相关资源
    最近更新 更多