【问题标题】:Getting error when Dropbox url copy to azure blob storageDropbox url 复制到 azure blob 存储时出错
【发布时间】:2022-03-01 16:04:00
【问题描述】:

我正在使用 azure blob 存储来复制 Dropbox 文件。但是当我尝试通过 URL 复制该文件时,出现 500 错误并且总字节数为 -1。

我正在使用 WindowsAzure.Storage.Blob 包的 StartCopy 方法。但是在这里我将 copyStatus.TotalBytes 设置为 -1 并且复制不起作用。

尝试了以下所有类型的url:

那么你能帮我解决这个问题吗?任何需要更改 URL 或任何将 Dropbox 媒体复制到 Azure Blob 存储的方式。

另外,我正在使用带有 C# 的 .net 4.8 框架。

示例代码:

string url = "https://dl.dropboxu`enter code here`sercontent.com/s/1v9re1dozilpdgi/1_32min.mp4?dl=0";
            Uri fileUri = new Uri(url);
            string filename = "test-file.mp4";
            var account = CloudStorageAccount.Parse(connectionstring);
            var blobClient = account.CreateCloudBlobClient();            
            var container = blobClient.GetContainerReference("test-container");
            var blob = container.GetBlockBlobReference(filename);

            blob.DeleteIfExists();
            blob.StartCopy(fileUri);

            var refBlob = (CloudBlockBlob)container.GetBlobReferenceFromServer(filename);
            var fileLength = refBlob.CopyState.TotalBytes ?? 0;

            while (refBlob.CopyState.Status == CopyStatus.Pending)
            {
                refBlob = (CloudBlockBlob)container.GetBlobReferenceFromServer(filename);
                var copyStatus = refBlob.CopyState;

}

错误消息:500 InternalServerError "复制失败。"

【问题讨论】:

标签: c# .net azure azure-blob-storage dropbox


【解决方案1】:

我们需要使用CloudBlockBlob,而不是使用GetBlockBlobReference

因为在其构造函数中将文件名而不是 URL 传递给 GetBlockBlobReference

更多信息请参考下面

SO THREAD 由@Tobias Tengler 建议

&这个博客:-Azure – Upload and Download data using C#.NET

【讨论】:

    猜你喜欢
    • 2018-08-18
    • 2017-04-01
    • 2016-02-12
    • 2018-03-11
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    相关资源
    最近更新 更多