Azure 存储 API 内容处置 [英] Azure Storage API ContentDisposition

查看:32
本文介绍了Azure 存储 API 内容处置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 Azure 已释放 blob 的 ContentDisposition 属性:http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.blob.blobproperties.contentdisposition(v=azure.10).aspx 在他们 3.0 版的 api 中.我已经在我现有的 blob 上设置了该属性,但是当它们被下载时,响应中不包含 content-disposition 标头.

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.

我已经验证,当我从 Azure 获取该 Blob 的属性时,ContentDisposition 属性实际上已填充.

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

它在使用 SAS 时有效,但在没有 SAS 的情况下下载文件时无效.

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

如果有人有见解,请告诉我.

If someone has insight please let me know.

推荐答案

您能否检查您的存储帐户的DefaultServiceVersion?为了使 Content-Disposition 起作用,我认为 DefaultServiceVersion 应该是 2013-08-15.

Can you please check the DefaultServiceVersion for your storage account? For Content-Disposition to work, I believe the DefaultServiceVersion should be 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,它应该可以工作了.

Once you set DefaultServiceVersion, it should work.

这篇关于Azure 存储 API 内容处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆