基于此处的 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/