I am using Azure Files to store files for my Web Application, which I have previously mentioned here.
I am currently processing the files/sub-directories within a directory, and outputting a navigation table so the user can navigate into sub-directories, and in the end, obtain said files. I'm doing this by using the methods described in the 'Access the file share programmatically' section of this Azure Documentation article.
My question is very simple, how can I, from my Web App, which is running in Azure app service, provide a public URL were the user can download/view the file?
Please note, I would prefer that the file is not automatically downloaded, since most of the files would be a .PDF
, and therefor preview-able in the browser.
My question is very simple, how can I, from my Web App, which is running in Azure app service, provide a public URL were the user can download/view the file?
One possible solution would be to create a Shared Access Signature (SAS)
on the files with at least Read
permission and use that SAS URL. Depending on the file's content type, the file's contents will be either displayed inline in the browser or the user will be prompted to download the file. If you want to force the download, you could always override Content-Disposition
response header in the SAS.
Using Shared Access Signature (SAS) could be a solution but it is probably an overkill in the given scenario.
In provided scenario the Blob Storage with public access is the most practical way to store files. From documentation:
... You can specify that a container and its blobs, or a specific blob, are available for public access. When you indicate that a container or blob is public, anyone can read it anonymously; no authentication is required. Public containers and blobs are useful for exposing resources such as media and documents that are hosted on websites. To decrease network latency for a global audience, you can cache blob data used by websites with the Azure CDN.
https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/
To set container permissions from the Azure Portal, follow these steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With