Send / receive images in response to http

We are currently developing an application with a React (and Express Server) frontend and a core Java component. The app needs to be able to send many images and videos between the frontend and backend.

We've been using fetch so far ( https://github.com/github/fetch ) to send images with formData from frontend to backend, but that doesn't work for sending another path (backend to frontend) due to an outstanding form data in sample. We can receive images as blobs, but we want to send information with files to reduce the number of HTTP requests.

Does anyone have any recommendations as to what we should use to send and receive large amounts of images and videos? Libraries or suggestions?

Thank you so much!

+3


source to share


1 answer


I really don't see a problem getting data with multiple requests. One request sends image information, with a link to the image, and then the browser sends another request to fetch the image. This is the most common implementation I've seen.

The consumer overhead of sending multiple requests to the server is not an issue. Modern browsers don't open multiple tcp connections to the server - they keep the connection open for some time to allow multiple requests without the overhead of opening new connections.

All modern web browsers use persistent connections, including Google Chrome, Firefox, Internet Explorer (from 4.01), Opera (from 4.0) and Safari. https://en.wikipedia.org/wiki/HTTP_persistent_connection



I assume what you are trying to do with "formData" is to send a response to the browser using content-type: multipart

in response. This is not common practice, and browser support looks inconsistent . Also, is there a de facto or established reason why multiprocessing HTTP responses are generally not supported in browsers? ...

What would really be helpful for your use case, though, is the adoption of the HTTP / 2 protocol. HTTP / 2 has many more options for persistent connections and multiple responses with the same connection.

With the new binary framing engine, HTTP / 2 no longer needs multiple TCP connections for parallel multiplex streams; each stream is split into multiple frames, which can be interleaved and prioritized. As a result, all HTTP / 2 connections are persistent, and only one connection is required per source, providing numerous performance benefits. https://developers.google.com/web/fundamentals/performance/http2/

+1


source







All Articles