locked
Copy file failed RRS feed

  • Question

  • Hello,

    I am using azure media service's job to generate the thumbnail. 

    The thumbnail is generated succesfully.

    Then I copy this file to the blob.

     CloudBlockBlob assetBlob =
                       this.blobContainer.Acquire(containerName)
                           .GetAssetReference(blobName);
                IAccessPolicy accessPolicy = 
                    await 
                    this.mediaContext.AccessPolicies.CreateAsync(
                        thumbnailFile.Name,
                        TimeSpan.FromMinutes(20), 
                        AccessPermissions.Read);
                ILocator locator = await this.mediaContext.Locators.CreateSasLocatorAsync(thumbnailAsset, accessPolicy);
                var url = $"{locator.BaseUri}/{thumbnailFile.Name}{locator.ContentAccessComponent}";
                await assetBlob.StartCopyAsync(new Uri(url));                 
                await locator.DeleteAsync();

                await accessPolicy.DeleteAsync();

    And when I try to download this file from the blob I get an exception: Calculated MD5 does not match existing property.

     Stream blobStream = new MemoryStream();
                var cloudBlob = this.client.GetBlobReferenceFromServer(new Uri(uri));
                cloudBlob.DownloadToStream(blobStream);
                blobStream.Seek(0, SeekOrigin.Begin);

                return blobStream;

    I can't disable MD5Validation. Is there any other way to fix it?

    Thanks in advance.

    Monday, November 13, 2017 6:40 PM

Answers

  • This could be that the blob property doesn't match the content of the blob itself. Try the following code to see if it could help by disabling the MD5 check:

    set DisableContentMD5Validation to true in BlobRequestOptions as below:

                BlobRequestOptions options = new BlobRequestOptions()

                {

                    DisableContentMD5Validation = true,

                };

                blockBlob.DownloadToStream(memoryStream, null, options);

    Let me know if this helps.


    Friday, December 1, 2017 5:23 PM

All replies

  • This could be that the blob property doesn't match the content of the blob itself. Try the following code to see if it could help by disabling the MD5 check:

    set DisableContentMD5Validation to true in BlobRequestOptions as below:

                BlobRequestOptions options = new BlobRequestOptions()

                {

                    DisableContentMD5Validation = true,

                };

                blockBlob.DownloadToStream(memoryStream, null, options);

    Let me know if this helps.


    Friday, December 1, 2017 5:23 PM
  • Is the copy sync or async? If async, did you wait for it to complete on the service? If not, the data won't be fully available.
    Friday, December 1, 2017 5:31 PM