TiagoOliveira
TiagoOliveira

Reputation: 505

Azure blob storage - Copy Block blobs in the SAME container

I'm using Azure Storage with the Android API. I'm trying to copy one block blob from one location to another (in the SAME blob container).

However, when I make the copy I get a "CannotVerifyCopySource" error after invoking the startCopy method.

Example Code:

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);
}

Any ideas on what might be the problem?

Best regards,

Upvotes: 1

Views: 369

Answers (1)

Alex Chen-WX
Alex Chen-WX

Reputation: 531

see source about startCopy below. I think you should use blob2.startCopy(blob1) here.

/**
     * 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 */);
    }

Upvotes: 1

Related Questions