Add file mimetype to blob properties
JL102 opened this issue · 1 comments
The current setup doesn't provide any way to specify the mimetype / content type of the file, leading to it defaulting to application/octet-stream. So if users open the URL of an image, it'll just download instead of showing in browser.
This small modification to the uploadToBlob function fixes it:
var options = {
contentSettings: {
contentType: file.mimetype,
}
}
var blobStream = that.blobSvc.createWriteStreamToBlockBlob(that.container, blobPath, options, function (error) {
if (error) {
cb(error);
}
});
This repo is going to be deprecated so we won't accept new feature requests.
Would you like to switch to V12: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob ?
It supports setting the content type when uploading a file with options.blobHTTPHeaders.blobContentType
:
https://docs.microsoft.com/en-us/javascript/api/@azure/storage-blob/blockblobclient?view=azure-node-latest#uploadFile_string__BlockBlobParallelUploadOptions_