Can you use javascript to render the image stream?

The situation is that you need to work with the image API, and you need to make a POST request to get the image stream that you want to display on the rest of your web page.

I can make an ajax request for this service when loading a page using jQuery, but I just get the returned binary stream. Is there anyway that JavaScript can take this binary string and display the type of content that is in the header?

+3
source share
5 answers

I believe that you are looking for a Data URI Scheme - this allows you to format a very long URI that indicates the necessary binary code for the data itself.

+3
source

I believe that you need to organize the delivery of the stream when the HTTP GET operation refers to the URL, then JavaScript should set the src attribute of the image to this URL. I saw this with ASP.NET, where the .ashx handler is used for streaming. He then links to http://site.com/images/imagehandler.ashx?parameters .

+2
source

src URL-, ajax ? ajax?

+1

make an iframe-targeted form request. this is the only way.

+1
source

Just use javascript to create an img element with a url that returns the image as src:

// jquery
$(#some-id).append('<img src="/get-image/?foo=bar"/>');
0
source

Source: https://habr.com/ru/post/1705446/


All Articles