Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 470
user109657 Avatar asked Aug 10 '14 10:08

user109657


Video Answer


1 Answers

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();
like image 100
Gaurav Mantri Avatar answered Oct 24 '22 01:10

Gaurav Mantri