In my Web API I use the following code for creating the blob:
var container = Client.GetContainerReference(DefaultContainer);
var blockBlob = container.GetBlockBlobReference(blobName);
blockBlob.UploadFromStream(fileStream);
blockBlob.Properties.ContentType = "video/mp4";
blockBlob.SetProperties();
I need the ContentType header value to be video/mp4 when the file is downloaded from outside.
However, when I downloading that file with external link, Azure doesn't add corresponding ContentType. (It doesn't attach actually any).
So, how can I achieve that?
You need to get the properties/metadata first before updating them, so your code should be:
var container = Client.GetContainerReference(DefaultContainer);
var blockBlob = container.GetBlockBlobReference(blobName);
blockBlob.UploadFromStream(fileStream);
// Set the content type
blockBlob.FetchAttributes();
blockBlob.Properties.ContentType = "text/html";
blockBlob.SetProperties();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With