The Problem
I recently came across the conundrum of files not being availble for download after I uploaded them to Windows Azure Storage.
The Cause
Usually the problem is an incorrect mime type, but since Azure does not have mime types I had to do some more digging.
The Solution
It turns out there is a property called “ContentType” that must be set on the Azure Storage Blob programatically – here is an example
CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);
if (GetFileExtension(filename).ToUpper() == “.SWF”)
{
blockBlob.Properties.ContentType = “application/x-shockwave-flash”;
}
else if (GetFileExtension(filename).ToUpper() == “.MP4”)
{
blockBlob.Properties.ContentType = “video/mp4”;
}
blockBlob.SetProperties();
Once I did that everything worked as intended.
|
Written By Steve French |
Leave a Reply