【问题标题】:Is it possible to set the content disposition of an existing Azure blob?是否可以设置现有 Azure blob 的内容处置?
【发布时间】:2014-10-03 08:33:29
【问题描述】:

基于 stimms 的回答: Azure Storage API ContentDisposition

以及在此处找到的信息: Friendly filename when public download Azure blob

我已经能够在上传新文件时设置内容处置。但我也希望能够设置现有文件的内容配置。

blob.Properties.ContentDisposition = string.Format("attachment;filename=\"{0}\"", friendlyName);

在上传文件之前设置效果很好,但如果我在现有的 blob 上尝试它就没有效果。

改变现有 blob 的内容配置是完全不可能的,还是我做错了什么?

【问题讨论】:

    标签: azure azure-storage azure-blob-storage


    【解决方案1】:

    是的。设置ContentDisposition 后,您只需在blob 上调用SetProperties() 方法。所以你的代码应该是:

                blob.FetchAttributes();//Fetch properties first so that you don't overwrite existing properties when you call SetProperties
                blob.Properties.ContentDisposition = string.Format("attachment;filename=\"{0}\"", friendlyName);
                blob.SetProperties();
    

    【讨论】:

      猜你喜欢
      • 2018-02-06
      • 2021-09-17
      • 2013-03-27
      • 2012-05-21
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多