我看到Azure已经在他们的api版本3.0中发布了blob的{Content = {3}}的ContentDisposition属性。我已经在我现有的blob上设置了属性,但是当它们被下载时,内容处置标头不包含在响应中。
我已经验证当我从Azure为该Blob提取属性时,实际上已填充了ContentDisposition属性。
使用SAS时可以正常工作,但在没有SAS的情况下下载文件时则无效。
如果有人有洞察力,请告诉我。
答案 0 :(得分:17)
您可以查看存储帐户的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
后,它应该有效。