2013-12-21 43 views
7

我看到Azure已經發布了api的3.0版本中的blob的ContentDisposition屬性:http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.blob.blobproperties.contentdisposition(v=azure.10).aspx。我已經將屬性設置爲現有的blob,但是當它們被下載時,content-disposition標頭不包含在響應中。Azure存儲API內容配置

我已驗證,當我爲該Blob的FetchAttributes屬性實際填充了ContentDisposition屬性時。

它在使用SAS時有效,但在沒有SAS的情況下下載文件時不起作用。

如果有人有見識,請讓我知道。

回答

12

您能查看您的存儲帳戶的DefaultServiceVersion嗎?要使Content-Disposition正常工作,我相信DefaultServiceVersion應該是2013-08-15

得到DefaultServiceVersion

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

設置DefaultServiceVersion

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

一旦您設置DefaultServiceVersion,它應該工作。

+0

嗨Gaurav,你知道如何重置服務版本級別?我BLOB帳戶的當前級別爲'空'。當我看到serviceProperties.DefaultServiceVersion。如果將來出現問題,我只想要一種方法將其重置爲空。我試圖通過代碼將其重置爲null,但它不起作用。 –