Azure IoT Python SDK how to set content type on uploaded images

199 views Asked by At

Uploading an image via the Python SDK, the "Content Type" in Azure Blob storage is always "application/x-www-form-urlencoded".

Certain applications, like Twilio, require a correct content type when accessing blob files, to render an MMS message.

I would like to request the ability to set the content Type at upload, vs. having to do it in code.

(For others) As a workaround, I am using the code below (include WindowsAzure.Storage from NuGet):

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

        static void ChangeContentType(string URI)
        {
            //Parse the connection string for the storage account.
            const string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=accountName;AccountKey=AccountKey";
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);

            //Create the service client object for credentialed access to the Blob service.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            ICloudBlob imageFile = blobClient.GetBlobReferenceFromServer(new Uri(URI));
            imageFile.Properties.ContentType = "image/jpeg";
            imageFile.SetProperties();
        }
0

There are 0 answers