Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage API ContentDisposition

I see that Azure has release the ContentDisposition property of a blob: http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.blob.blobproperties.contentdisposition(v=azure.10).aspx in their version 3.0 of the api. I've set the property on my existing blobs, but when they are downloaded the content-disposition header is not included in the response.

I've verified that when I FetchAttributes the properties from Azure for that Blob that the ContentDisposition property is in fact populated.

It does work when using SAS, but not when downloading the file without SAS.

If someone has insight please let me know.

like image 427
mp-mi Avatar asked Dec 21 '13 13:12

mp-mi


1 Answers

Can you please check the DefaultServiceVersion for your storage account? For Content-Disposition to work, I believe the DefaultServiceVersion should be 2013-08-15.

To get DefaultServiceVersion:

    var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), false);
    var serviceProperties = cloudStorageAccount.CreateCloudBlobClient().GetServiceProperties();
    var serviceVersion = serviceProperties.DefaultServiceVersion;

To set DefaultServiceVersion:

    var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), false);
    var serviceProperties = cloudStorageAccount.CreateCloudBlobClient().GetServiceProperties();
    serviceProperties.DefaultServiceVersion = "2013-08-15";
    cloudStorageAccount.CreateCloudBlobClient().SetServiceProperties(serviceProperties);

Once you set DefaultServiceVersion, it should work.

like image 112
Gaurav Mantri Avatar answered Sep 21 '22 16:09

Gaurav Mantri