Uploading blockblob and setting contenttype

后端 未结 6 1111
旧巷少年郎
旧巷少年郎 2020-12-15 16:20

I\'m using Microsoft.WindowsAzure.Storage.* library from C#.

This is how I\'m uploading things to storage:

// Store in storage
CloudStor         


        
6条回答
  •  再見小時候
    2020-12-15 16:54

    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 image
    CloudBlockBlob blockBlob = container.GetBlockBlobReference("blah.jpg");
    blockBlob.Properties.ContentType = "image/jpg";
    blockBlob.UploadFromByteArray(byteArrayThumbnail, 0, byteArrayThumbnail.Length);
    

    and that should do the trick.

提交回复
热议问题