【问题标题】:Azure Storage API ContentDispositionAzure 存储 API 内容处置
【发布时间】:2014-01-10 06:16:17
【问题描述】:

我看到 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 获取该 Blob 的属性时,ContentDisposition 属性实际上已被填充。

在使用 SAS 时确实有效,但在没有 SAS 的情况下下载文件时无效。

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

【问题讨论】:

    标签: azure azure-blob-storage


    【解决方案1】:

    您能否查看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,它应该可以工作了。

    【讨论】:

    • 您好 Gaurav,您知道如何重置服务版本级别吗?我的 BLOB 帐户的当前级别为“空”。当我看到 serviceProperties.DefaultServiceVersion。如果将来出现问题,我只是想要一种将其重置为 null 的方法。我尝试通过代码将其重置为空,但它不起作用。
    猜你喜欢
    • 2021-09-17
    • 2018-11-25
    • 1970-01-01
    • 2016-12-07
    • 2016-08-30
    • 1970-01-01
    • 2014-03-29
    • 2021-07-08
    • 2020-05-02
    相关资源
    最近更新 更多