如何从网站图片上传文件到 Azure Blob Storage?

How can upload files to Azure Blob Storage from web site images?

如何将文件从 www.site.com/amazing.jpg 上传到 Azure Blob 存储? 多个文件从 url 上传到 Azure Blob 存储。 我找不到这种方式。我试了很多方法都不成功:( 谢谢你的帮助

实际上很简单,您可以让 Azure 存储为您完成这项工作:)。

基本上你要做的是调用Copy Blob操作。通过此操作,您可以指定任何可公开访问的 URL,Azure 存储服务将通过复制 URL.

的内容在 Azure 存储中为您创建一个 blob。
        var cred = new StorageCredentials(accountName, accountKey);
        var account = new CloudStorageAccount(cred, true);
        var client = account.CreateCloudBlobClient();
        var container = client.GetContainerReference("temp");
        var blob = container.GetBlockBlobReference("amazing.jpg");
        blob.StartCopy(new Uri("www.site.com/amazing.jpg"));
        //Since copy is async operation, if you want to see if the blob is copied successfully, you must check the status of copy operation
        do
        {
            System.Threading.Thread.Sleep(1000);
            blob.FetchAttributes();
            var copyStatus = blob.CopyState.Status;
            if (copyStatus != CopyStatus.Pending)
            {
                break;
            }
        } while (true);
        Console.WriteLine("Copy operation finished");