This is my first question on Stackoverflow.
I'm facing an architecture issue more than a programming one.
I'll explain the topic : I'm working with Microsoft Azure Cloud Service solution.
I have a WorkerRole which encrypts uploaded pictures and stores them in a Blob.
Then I have a WebRole with which I want to display this picture in a browser, within an image controller.
I managed to get an encrypted picture from a blob to local storage and to decrypt it.
At this point, I looked how to display pictures stored in WebRole LocalStorage when I found this. The answer explains that it's a bad idea to use local storage to serve picture since each request can hit different instances of my webRole.
So, here i'm stuck, how can I serve my decrypted pictures to my image controller without having an unencrypted copy of my picture in the blob ?
Solution Define a web handler which download picture from blob to webrole, then decrypt it and return this.
public class Images : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
String imgPath;
String imgName = context.Request.QueryString["imgName"];
imgPath = getFromStorage(imgName);
context.Response.ContentType = "image/png";
context.Response.WriteFile(imgPath);
}
}
In your image web control :
<asp:Image ID="imgViewer" ImageUrl="Images.ashx?imgName=mypicture.png"/>