AlexanderYpema_Infi
AlexanderYpema_Infi

Reputation: 57

Getting an MD5 of a remote file blob in Azure node js SDK

I'm writing a backup script that will pull a full copy of every file in a specific blob container in our Windows Azure blob storage. These files are not uploaded by me, I'm just writing a script that traverses the blob storage and downloads the files. To speed up this process and skip unnecessary downloads, I'd like to request MD5s for the files before downloading them, and compare them with the already local files.

My problem: I can't find documentation anywhere detailing how to do this. I'm pretty sure the API supports it, I'm finding docs and answered questions related to other languages everywhere, but not for the Node.js Azure SDK.

My question: Is it possible, and if yes, how, to request an MD5 for the remote file blob through the Azure Node.js SDK, before downloading it? And is it faster than just downloading the file?

Upvotes: 0

Views: 2156

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136356

It is certainly possible to get blob's MD5 hash. When you list blobs, you'll get MD5 in blob's properties. See the sample code below:

var azure = require('azure');
var blobService = azure.createBlobService("accountname", "accountkey");

blobService.listBlobs("containername", function(error, blobs){
    if(!error){
        for(var index in blobs){
            console.log(blobs[index].name );
            console.log(blobs[index].properties['content-md5'] );
        }
    }
});

Obviously the catch is that blob should have this property set. If this property is not set, then an empty string is returned.

Upvotes: 1

Related Questions