c# - Web Api 2 - How do i return an image (MemoryStream from Azure Storage) from a HTTPGET without saving to disk ? -
I am using Web API 2 with C # and Ezur, and how to return image (base from memorystream) To display on the page ...
Here my administrator HTTPGET
[root ("API / PhotoSmit / GetPhoto / {ID}")] [httpTPA] Public HttpResponseMessage GetPhotoById (Int ID) {storage service storage = new storage service (); MemoryStream MS = Storage. DownloadBlock (ID); // Return what? }
Here is the beginning of the escape:
$ http ({method: 'GET', url: 'api / PhotoSubmit / GetPhoto /' + $ RouteParams.id, accept: 'application / json'}) .success (function (results) {// How do I handle the result and how should I use HTML? & Lt; img?});
Hope someone has knowledge of this and can help me with this "show-stopper";)
You do not need to use $ http from the client side. You can simplify the process by using plain old HTML ...
& lt; Img src = "/ api / PhotoSubmit / GetPhoto / 2232" />
Use JQuery for dynamic images like this ...
$ ('# ImageLocation'). Html ('& lt; img src = "/ API / PhotoSubmit / GetPhoto /' + EIID + '" / "gt;');
The HTTP request will work, you must save all the complexities.
On the server side, you perform such a process to load the file and stream it to the client. It is important that the server code is correct MIME type returns such as ...
context.Response.ContentType = "image / png";
Resource:
< P>... and ...
Comments
Post a Comment