How to get download url of a digital file stored in an Azure storage account
Asked Answered
M

1

5

After storing a digital file in Azure blob storage, I want to provide a link to that file in my static website (that has no server side code). When a user clicks on that link user should be able to download that digital file to his/her computer. Question: How do you get the url of a digital file stored in Azure blob storage?

Morissa answered 8/3, 2020 at 1:40 Comment(3)
You mean something like account.blob.core.windows.net/container-name/digital-file-name?Contravene
@GauravMantri A URL of my digital file in Azure blob storage that - when a user clicks on - should immediately download the digital file to his/her computer (download folder). User's browser would of course give a warning if you want to download this file - but that is off topic here.Morissa
Provided an answer. Not sure if this is what you're looking for. HTH.Contravene
C
11

Each blob in Azure Storage has a URL of the following format:

https://account.blob.core.windows.net/container/blob

Where:

account is the name of your storage account, container is the name of your blob containerandblob` is the name of your blob.

Now that your requirement is that a user should be prompted to download the file directly without using any server-side code, these are the additional things you would need to do:

  1. Make sure that the blob container's ACL is either set to Blob (recommended) or Public. If you set the ACL to Private, then you would need a Shared Access Signature (SAS) and that would require some server-side code.
  2. Either set the content-type of the blob to application/octet-stream (default content type for any blob in Azure Storage) or set the content-disposition property to attachment; filename="your file name" to force the file download instead of displaying it inside the browser only. Recommended approach is to use content-disposition property.
Contravene answered 8/3, 2020 at 2:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.