Reputation: 697
I have the following code on my page:
<a class="btn-default btn" href="<AzureBlobContainerUrl>/<guid>.psd" download="@Model.FileName" target="_blank">Download
<span class="glyphicon glyphicon-export"></span>
</a>
@Model.FileName represents e.g. 'MyPhotoshopFile.psd'
First Problem: The downloaded file has the original GUID as filename not e.g. 'MyPhotoshopFile.psd'.
Second Problem: If the file is a e.g. PDF then Google opens the file directly in the current browser tab instead of downloading it.
Any solutions for that?
Upvotes: 0
Views: 311
Reputation: 697
Well, thank you very much for your tips! First, the code and your advice weren't working (the C-D attribute was ignored by azure blos storage services), but after some hours of research I identified the issue:
I recreated the blob storage and used the legacy BlobStorage account type. With this the ContentDisposition Attribute is working.
Upvotes: 0
Reputation: 5977
For the first problem, try setting the Content-Disposition property on the blob. If you're using the C# SDK, then grab the blob and you can set the C-D using something like this:
blob.FetchAttributes();
blob.Properties.ContentDisposition = string.Format("attachment;filename=\"{0}\"", yourFileName);
blob.SetProperties();
Based on this older question (Chrome Download Attribute not working), the "download" attribute in Chrome behaves differently based on the C-D, so setting this explicitly will likely solve your second problem.
Upvotes: 1