use*_*657 3 azure azure-storage azure-storage-blobs
基于此处的 stimms 答案: Azure Storage API ContentDisposition
以及在此处找到的信息: 公开下载 Azure blob 时的友好文件名
我已经能够在上传新文件时设置内容配置。但我也希望能够设置现有文件的内容配置。
blob.Properties.ContentDisposition = string.Format("attachment;filename=\"{0}\"", friendlyName);
Run Code Online (Sandbox Code Playgroud)
在上传文件之前设置时工作正常,但如果我在现有 blob 上尝试它则无效。
更改现有 blob 的内容配置是完全不可能的,还是我做错了什么?
是的。您只需要SetProperties()在设置后调用blob 上的方法ContentDisposition。所以你的代码应该是:
            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();
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           4580 次  |  
        
|   最近记录:  |