lloyd christmas
lloyd christmas

Reputation: 576

Are file extensions necessary for Azure blobs?

I'm using an Azure storage account to store images and files as block blobs.

Browsers seem to be able to serve images correctly without an extension as long as the content type property is set. For example this will show up as a normal image: https://navhomeprod.blob.core.windows.net/facilityroomphotos/12

Would it be better for any reason to save the blob name with an extension: https://navhomeprod.blob.core.windows.net/facilityroomphotos/12.jpg

The reason I chose not to have extensions is so that I didn't need an extension field in the database, I could just use ids to serve the images.

Upvotes: 4

Views: 5587

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136366

Simple answer is no. You don't really need to specify a file extension in order to serve images. The catch here is that content type should be set properly. Content type tells browsers how to serve the content.

Even if you have the extension set but content type not set, some browsers will not be able to serve the content in that case. I have seen many questions where Chrome prompted to download an image file instead of showing the content inline if the content-type of that image file not set properly.

One use case that I could think of where the file extension will be handy is when you download these files on your local computer. Based on the file extension, your local computer would decide the application to use to view/edit these files.

Upvotes: 6

Related Questions