Azure Storage Explorer: upload files with the correct Content-Type

Azure Storage Explorer: upload files with the correct Content-Type

If you use any type of Azure Storage (or even CosmosDB), you must know Azure Storage Explorer.

This is a tool based on Electron and available for Windows, Mac OSX and Linux, that allows to quickly browse your storage spaces and CosmosDB databases.

Recently, I was benefitting from static website hosting in Azure storage. Essentially it allows you to host the files of a static website on Azure Storage and access it via http protocol, typically from an address like https://xxxxx.xx.web.core.windows.net/.

When uploading the files of my static website, I've found that the content type of JavaScript files was set to text/plain instead of text/javascript, and because of this, my static website was not able to correctly download the JavaScript files.

The issue was tracked in this GitHub issue.

Look from the issue itself an picture of the wrong behaviour:

Storage-Explorer-Wrong

Luckily, the same GitHub issue reports how to fix this problem, linking the solution to this StackOverflow question.

Essentially, the Storage Explorer honors the content types you have defined in your local computer. You can verify it as well opening the RegEdit utility and going to HKEY_LOCAL_MACHINE\Software\Classes and then your extension.

In fact, I have verified that in my case the content type associated to the js file was indeed text/plain:

Storage-Explorer-JavaScript-1

Following the recommendations, I have changed it to text/javascript:

Storage-Explorer-JavaScript-2

Uploading now the files again, I got the correct content type!

Storage-Explorer-Correct