现有的Azure Blob的内容处置是否可能? [英] Is it possible to the content disposition of an existing Azure blob?
问题描述
基于stimms在这里回答: Azure Storage API ContentDisposition
Based on stimms answer here: Azure Storage API ContentDisposition
以及在此处找到的信息: 公共下载Azure blob时的友好文件名
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);
在上传文件之前进行设置时可以很好地工作,但是如果在现有的Blob上尝试它没有任何作用.
works fine when set before uploading a file, but has no effect if I try it on an existing blob.
更改存在的Blob的内容处置只是根本不可能还是我做错了什么?
Is is just plain impossible to change the content disposition of an existing blob or am I doing something wrong?
推荐答案
是.设置ContentDisposition
后,只需在Blob上调用SetProperties()
方法即可.因此您的代码应为:
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();
这篇关于现有的Azure Blob的内容处置是否可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!