gpt4 book ai didi

azure - CloudBlobClient.startCopyAsync() 的源代码

转载 作者:行者123 更新时间:2023-12-03 05:48:31 25 4
gpt4 key购买 nike

来自documentation函数 CloudBlobClient.StartCopyAsync()

它说

Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

我希望知道该函数是否会在进程启动或完成后返回。这个功能的实现是否开源?

这里是一个部分类: https://github.com/Azure/azure-storage-net/blob/master/Lib/WindowsRuntime/Blob/CloudBlobClient.cs

最佳答案

在内部,CloudBlockBlob.StartCopyAsync() 调用 Copy Blob REST API。

一旦进程启动,函数就会返回:

In version 2012-02-12 and newer, the Copy Blob operation can complete asynchronously. This operation returns a copy ID you can use to check or abort the copy operation. The Blob service copies blobs on a best-effort basis.

The source blob for a copy operation may be a block blob, an append blob, or a page blob, or a snapshot. If the destination blob already exists, it must be of the same blob type as the source blob. Any existing destination blob will be overwritten. The destination blob cannot be modified while a copy operation is in progress.

In version 2015-02-21 and newer, the source for the copy operation may also be a file in the Azure File service. If the source is a file, the destination must be a block blob.

下面是调用CloudBlockBlob.StartCopyAsync()后主动检查复制状态的源代码:

await targetCloudBlob.StartCopyAsync(sourceCloudBlob.Uri);

while (targetCloudBlob.CopyState.Status == CopyStatus.Pending)
{
await Task.Delay(100);
await targetCloudBlob.FetchAttributesAsync();
}

if (targetCloudBlob.CopyState.Status != CopyStatus.Success)
{
Console.WriteLine("Copy failed: {0}", targetCloudBlob.CopyState.Status);
}

关于azure - CloudBlobClient.startCopyAsync() 的源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50867014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com