node.jsazureazure-storagecontenttype

How to set contenttype on azure blob storage with nodejs


I've got a nodejs server, am using the azure-storage module and am trying to upload a wav file to azure blob storage.

I'm trying to set the contentType on the blob to 'audio/wav' but it is showing up in storage as 'application/octet-stream'. Code is:

 upload: function (id, buffer, mimeType, callback) {
    self = this;
    var size = buffer.length;
    var stream = streamifier.createReadStream(buffer);
    var options = { contentType: 'audio/wav' };
    self.blobService.createBlockBlobFromStream(self.containerName, id, stream, size, options,  function (error, result, response) {
        if (error) {
            callback(error);
        }
        callback(null);
    });
}

Any ideas as to what I'm doing wrong?


Solution

  • According the comments in source code at Github, the option architecture has changed, to define the contentType, please try to use following code snippet:

    var options = {contentSettings:{contentType:'audio/wav'}}
    

    Any further concern, please feel free to let me know.