codingoutloud
2/13/2013 - 7:24 PM

Snippet of Azure Client SDK 1.7 code that demonstrates setting ContentType and CacheControl headers.

Snippet of Azure Client SDK 1.7 code that demonstrates setting ContentType and CacheControl headers.

// .NET Storage SDK 1.7

CloudBlob destBlob = TargetContainer.GetBlobReference(destFileName);

destBlob.Properties.ContentType = "image/jpeg";
destBlob.Properties.CacheControl = "x-ms-blob-cache-control: public, max-age=31556926"; // cache for up to one year 
try
{
   destBlob.UploadFile(sourceFilespec);         
}
catch(Exception ex)
{
   logger.ErrorFormat("UploadFile exception: {0}", ex.ToString());
}