How do I display an image saved in Azure File Services in an img tag?
I am getting started with Azure File Services and have a "duh" moment; I am missing something obvious.
I figured out the API, created a share, and downloaded an image from API.net (not REST API).
Url
http://cooperwrite.file.core.windows.net/cwfiles/me.jpg
is a picture of me. I thought (but clearly wrong) that this url is also a public url that I would use to render the image.
When I try to access it, I get an error. I am assuming this url is used to access the file for REST API purposes, but how do I get the url that I would put in the tag?
This issue has a security issue but I can't find any watch faces to flip over.
Thank,
John
source to share
The short answer is that you cannot.
Essentially, in order to display an image using a tag img
, your browser must access the resource anonymously. Currently, all requests to a file service resource must be authorized (using an authorization scheme SharedKey
or ShareKeyLite
), so you cannot access a resource in a file service by specifying only the URL.
It is best for this time to use Azure Blob Storage
and save the file in the container using Blob
or Public
ACL. If your blob ACL is private, you will need an image Shared Access Signature (SAS)
permission Read
(in which case the SAS token must be included in the url) to be displayed directly in the browser.
source to share