Explore Courses Blog Tutorials Interview Questions
0 votes
in Azure by (20.3k points)

We have a website hosted on Azure. It is media based, and we are using JWPlayer to playback media with HTTP pseudostreaming. The media files are stored on blob in 3 formats - mp4, ogg, webm.

The issue is the content type of media files is set as application/octet-stream for all types. Due to this there are some issues in media playback and progress bar.

How can I set the appropriate Content-type of files stored on blob (like - video/mp4, video/ogg, video/webm)?

I do not want to do it manually for each file by going in blob interface. There must be some other way to do it which I am not aware of. Perhaps a config file, settings file, etc sorts. Or perhaps a code block to set up the Content-type for all files stored in a folder.

Any suggestions? Thanks

1 Answer

0 votes
by (119k points)

This should work:

var storageAccount = CloudStorageAccount.Parse("YOURCONNECTIONSTRING");

var blobClient = storageAccount.CreateCloudBlobClient();

var blobs = blobClient


    .ListBlobs(useFlatBlobListing: true)


foreach (var blob in blobs)


    if (Path.GetExtension(blob.Uri.AbsoluteUri) == ".mp4")


        blob.Properties.ContentType = "video/mp4";


    // repeat ad nauseam



Or set up a dictionary so you don't need to write a lot of if statements.

If you are looking for an online course to learn Azure, check out this Azure Training Course by Intellipaat.

Browse Categories