background:
I'm trying to force the browser to download an image in response to a button (or link) click, instead of showing it inline. I need this to work cross browsers, so HTML5 attributes aren't enough.
The Image is stored in a blob (azure storage services).
What I tried:
To set the DefaultServiceVersion to 2013-08-15 so the contentDisposition will work. (example from here Azure Storage API ContentDisposition):
var cloudStorageAccount = new CloudStorageAccount(new StorageCredentials("accountname", "accountkey"), false); var serviceProperties = cloudStorageAccount.CreateCloudBlobClient().GetServiceProperties(); serviceProperties.DefaultServiceVersion = "2013-08-15"; cloudStorageAccount.CreateCloudBlobClient().SetServiceProperties(serviceProperties);
To set the content disposition property (example from http://www.tuicool.com/articles/AFbmY3):
blob.Properties.ContentDisposition = "attachment; filename=" + downloadName;
To Call the image from a link click\window.open(image_url)\window.location = image_url. With fiddler in the background.
The problem: The image is shown by IE as an in-line image. Checking on fiddler and see that:
The contentDisposition doesn't exist in the response header.
The x-ms-version in the response is not the one I set as the default one. I'm Keep getting the old version 2009-09-19.
So I also tried to generate the request directly from fiddler, with the x-ms-version specified in the request header. This does work and I'm getting the response I'm expecting for, with the contentDisposition property and the right x-ms-version (the one I added to the request - 2013-08-15).
I understand that the problem is with the default service version and when i check (while debugging) the value of the DefaultServiceVersion property I do see the right value(2013-08-15), but still the response contains the old value.
I can't add x-ms-version to the header while generating the request from a link (or from window.open) and I don't really understand why the default value I added isn't working.
Thanks in advance for any help or suggestion how to solve this issue.