azure - 是否可以设置现有 Azure blob 的内容处置?

标签 azure azure-storage azure-blob-storage

基于此处的 stimms 答案: Azure Storage API ContentDisposition

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

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

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

在上传文件之前设置时工作正常,但如果我在现有 blob 上尝试它则没有效果。

更改现有 blob 的内容配置是根本不可能的还是我做错了什么?

最佳答案

是的。设置 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();

关于azure - 是否可以设置现有 Azure blob 的内容处置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25227608/

相关文章:

azure - AD B2C 自定义策略自定义声明在注册时出现错误 "Unable to validate the information provided."

azure - Save-AzureRmVMImage 强制创建无效的 blob 容器名称

powershell - azure查找并删除未附加的磁盘

java - 使用有限堆的 azure-sdk-for-java 上传大文件

c# - DownloadToStreamAsync 返回空流 C#

azure - 在应用程序见解中禁用另存为查询

Python Azure SDK : How to retrieve secrets from keyvault?

WordPress 主题 git 部署到 windows azure

Azure 存储 - 每个容器的自定义域

python - Azure 函数 (python) 将输出写入输出 blob 路径的动态命名