简体   繁体   中英

Getting error when Dropbox url copy to azure blob storage

I am using the azure blob storage to copy the dropbox file. But when I try to copy that file via URL, got the 500 error and totalbytes are -1.

I am using StartCopy method of WindowsAzure.Storage.Blob package. But here I get the copyStatus.TotalBytes as -1 and copy not working.

Tried the all types of url as below:

So can you please help me to solve this issue? Anything needs to change in URL or any way to copy the dropbox media to azure blob storage.

Also, I am using the .net 4.8 frameworks with the C#.

Sample Code:

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;

}

Error message: 500 InternalServerError "Copy failed."

We need to use CloudBlockBlob instead of using GetBlockBlobReference .

Because the filename, not the URL, is passed to GetBlockBlobReference in its Constructor.

For more information please refer the below

SO THREAD as suggested by @ Tobias Tengler

& This BLOG:- Azure – Upload and Download data using C#.NET

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM