nam
nam

Reputation: 23749

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

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?

Upvotes: 5

Views: 13988

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136146

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.

Upvotes: 11

Related Questions