Is it possible to the content disposition of an existing Azure blob?

ぐ巨炮叔叔 提交于 2019-12-11 03:48:09

问题


Based on stimms answer here: Azure Storage API ContentDisposition

and the information found here: Friendly filename when public download Azure blob

I have been able to set the content disposition when uploading new files. But I also would like to be to able to set the content disposition of existing files.

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

works fine when set before uploading a file, but has no effect if I try it on an existing blob.

Is is just plain impossible to change the content disposition of an existing blob or am I doing something wrong?


回答1:


Yes. You just have to call SetProperties() method on the blob after you set ContentDisposition. So your code should be:

            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();


来源:https://stackoverflow.com/questions/25227608/is-it-possible-to-the-content-disposition-of-an-existing-azure-blob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!