Julyflowers
Julyflowers

Reputation: 133

Render Azure Blob content in android WebView

I have an HTML file that is stored in Azure Blob, and I am trying to render it in WebView element in my android app. I have stored my file with the extension html - and could see the file's type as text/html in the portal, and in my app I am fetching the blob's url and passing it to the webView.loadURL(<blob's url>). But I get the error message "Resource not found" in the emulator.

Is rendering a blob content in webView even a supported operation, or I should only resort to read the content from the blob using blob.OpenInputStream() and display it?

Upvotes: 1

Views: 647

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136336

If you wish to display the contents of a blob by specifying just its URL, there are two ways you can go about it:

  1. Change Container ACL: You would need to change the ACL of blob container holding the blob to either Blob or Container. This way the blob can be accessed anonymously using its URL.
  2. Use Shared Access Signature: If you want to keep the ACL of the container as Private, then other option for you would be to use a Shared Access Signature (SAS). A SAS gives time-limited permissions on a storage resource (Blob, Table, Queue, File etc.). In your case, you would need to create a SAS with at least Read permission. Once you get the SAS, you just need to append it to your blob URL and you should be able to access the blob from a private container. Please see this link for more details regarding SAS: https://azure.microsoft.com/en-in/documentation/articles/storage-dotnet-shared-access-signature-part-1/.

Upvotes: 1

Related Questions