Upload Images in Azure blob storage

Theodor Chichirita
2 min readJul 25, 2018

While I was working on a different project, i stumbled upon a very strange issue, the images from my blob storage container embedded in html didn’t display correctly:

broken image from azure blob

The image was embedded in a simple img tag:

After a little investigation i found out that this would happen when the image was bigger than a certain size, but something other than the size changed that broke the image link, the content type. It changed from “image/jpeg” to “application/octet-stream”.

To solve this, i decided to write a cli utility that uploads a jpeg image to a blob storage container with the correct content-type.

The main part of the application is the upload class that sets the content-type of the blob as image/jpeg, here is how:

IMPORTANT: blobReference.Properties.ContentType = “image/jpeg” must be set before uploading the file.

For the full source code go to: https://github.com/estatheo/blobUploadCLI

--

--