Uploading blockblob and setting contenttype Uploading blockblob and setting contenttype azure azure

Uploading blockblob and setting contenttype


Actually you don't have to call SetProperties method. In order to set content type while uploading the blob, just set the ContentType property before calling the upload method. So your code should be:

// Save imageCloudBlockBlob blockBlob = container.GetBlockBlobReference("blah.jpg");blockBlob.Properties.ContentType = "image/jpg";blockBlob.UploadFromByteArray(byteArrayThumbnail, 0, byteArrayThumbnail.Length);

and that should do the trick.


After you make any changes to Properties, you have to make a call to CloudBlockBlob.SetProperties() to actually save those changes.

Think of it as something similar to LINQ-to-Entities. You can make any changes you want to your local object, but until you call SaveChanges(), nothing is actually saved.


Using the new SDK Azure.Storage.Blobs

BlobHttpHeaders blobHttpHeaders = new BlobHttpHeaders();blobHttpHeaders.ContentType = "image/jpg";blobClient.SetHttpHeaders(blobHttpHeaders);