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?
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With