Verify the value of Content-MD5 in the response of PUT Block List

Kyoung 1 Reputation point
2021-03-25T04:56:26.057+00:00

Hi,
I want to verify the value of Content-MD5 in the response of Put Block List to upload a big file.
In Azure doc, I see the description below.
"This header refers to the content of the request, meaning, in this case, the list of blocks, and not the content of the blob itself."
But, it does not give any hint to calculate my own value and check against the value that I recieved.
Please let me know how to calculate this value.
Thanks in advance !

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,427 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sumarigo-MSFT 43,641 Reputation points Microsoft Employee
    2021-03-25T11:49:00.863+00:00

    @Kyoung Welcome to Microsoft Q&A, Thank you for posting your query!

    The best practice is that you always calculate hash of a downloaded blob and keep it as baseline to compare next time.

    As I understand you you are referring: Blobs uploaded by PutBlob will have Content-MD5 calculated by Storage service. But Blobs uploaded PutBlock/PutBlockList won’t have it, and client needs to calculate locally and set it to x-ms-blob-content-md5 Blob property explicitly. When client doesn’t do it, it’s empty. Above recommendation is based on such different cases. Reference: https://technet2.github.io/Wiki/blogs/windowsazurestorage/windows-azure-blob-md5-overview.html

    Additional information: Please refer to this GitHub article

    Hope this helps!

    Kindly let us know if the above helps or you need further assistance on this issue.

    --------------------------------------------------------------------------------------------------------------------------------

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob has a handful of conditions around when MD5 will/won’t be stored.


  2. Kyoung 1 Reputation point
    2021-03-25T21:31:35.407+00:00

    Hi,

    Thanks for the quick reply !
    The link you suggested, Windows Azure Blob MD5 Overview, helped me understand the background concept.

    But still there is no answer to my question.
    I will explain a little more details of my issue.

    I am trying to upload a big file using PutBlock and PutBlockList.
    After PutBlock requests are done, I send a request of PutBlockList with the following content in the body.

    <BlockList><Latest>TURBd01EQXdNREF3TURBd01EQXdNREF3T01Bd01EQXdNREF3TURBd01EQSUzRA==</Latest><Latest>...</Latest>...<Latest>...</Latest></BlockList>

    Then, in the response of PutBlockList, I get the Content-MD5 as below.

    HTTP/1.1 201 Created
    Content-Length: 0
    Content-MD5: 3n1Wn5onWkdA7ogldWIKXA==
    Last-Modified: Thu, 23 Mar 2021 18:25:58 GMT
    ETag: "0x8D8EFBB9331C89E"
    ...

    My question is how 'Content-MD5: 3n1Wn5onWkdA7ogldWIKXA==' is calculated in the Azure Storage Service.
    I really need to calculate and verify this value in my application side, too
    This issue is specific to my application. :-)

    In the MD5 overview page you mentioned, I see the following.

    "In a PutBlockList, the Content-MD5 header would provide transactional integrity for the message contents (the block list in the request body) , while ..."

    So, I tried to generate MD5 value with the content in the body of the **PutBlockList" request,
    but, I got a different value.
    I think there is a specific format / way to calculate the MD5 value.
    Please help me generate the same MD5 value.

    Thanks !

    0 comments No comments

  3. rogerdpack 1 Reputation point
    2021-09-24T18:31:49.427+00:00

    technet2.github.io/Wiki/blogs/windowsazurestorage/windows-azure-blob-md5-overview.html may be useful, Content-MD5 basically applies to each transfer body itself, good luck!

    0 comments No comments