use*_*596 5 azure azure-storage-blobs
我在远程网址上有一个文件,例如http://www.site.com/docs/doc1.xls,我想将该文件复制到我的BLOB存储帐户.
我知道并知道将文件上传到BLOB存储但不知道如何从远程URL对文件进行此操作.
如果您使用的是.NET客户端库,请尝试查看带有URI的CloudBlockBlob.StartCopyFromBlob.
string accountName = "accountname";
string accountKey = "key";
string newFileName = "newfile2.png";
string destinationContainer = "destinationcontainer";
string sourceUrl = "http://www.site.com/docs/doc1.xls";
CloudStorageAccount csa = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
CloudBlobClient blobClient = csa.CreateCloudBlobClient();
var blobContainer = blobClient.GetContainerReference(destinationContainer);
blobContainer.CreateIfNotExists();
var newBlockBlob = blobContainer.GetBlockBlobReference(newFileName);
newBlockBlob.StartCopyFromBlob(new Uri(sourceUrl), null, null, null);
Run Code Online (Sandbox Code Playgroud)
Gaurav第一次出现时就发布了这个消息.方便,他的帖子显示了如何观察完成,因为操作是异步.
| 归档时间: |
|
| 查看次数: |
3820 次 |
| 最近记录: |