Reputation: 14995
I am trying to update the contentType of an uploaded file or at least be able to reupload a file with the correct contentType.
In my case I am uploading css but it gives it a content type of application/octet-stream by default.
The command line reference doesn't show how to manage the properties of a blob as far as I can tell
Edit
If you just create the file apparently you can use
azure storage blob create -f {file_name} -p contentType=text/css
But I still haven't found a way to edit one yet.
Upvotes: 2
Views: 2412
Reputation: 4830
You can now set blob properties using az storage blob update
from the Azure CLI (source on GitHub). For example, to set the Content-Type
of a blob named $blob
in a container named $container
to text/css
:
az storage blob update -c "$container" -n "$blob" --content-type text/css
Upvotes: 3
Reputation: 136216
Looking at the source code here
, I don't think it is possible to update blob's properties using azure-cli.
If you're interested, you can use Node SDK for Azure Storage
and update blob properties. For example, look at the sample code below:
var AZURE = require('azure-storage');
var blobService = AZURE.createBlobService("<account name>", "<account key>");
var container = '<blob container name>';
var blob = '<blob name>';
var newContentType = '<new content type e.g. text/css>'
blobService.getBlobProperties(container, blob, function(error, result, response) {
if (!error) {
var contentType = result.contentType;
var cacheControl = result.cacheControl;
var contentEncoding = result.contentEncoding;
var contentMD5 = result.contentMD5;
var contentLanguage = result.contentLanguage;
var options = {
'contentType': newContentType,
'cacheControl': cacheControl,
'contentEncoding': contentEncoding,
'contentMD5': contentMD5,
'contentLanguage': contentLanguage,
};
blobService.setBlobProperties(container, blob, options, function(error, result, response) {
if (!error) {
console.log('Properties updated successfully!');
} else {
console.log(error);
}
});
} else {
console.log(error);
}
});
Upvotes: 1