A
A
Andrei Smirnov2017-11-03 17:33:29
RESTful API
Andrei Smirnov, 2017-11-03 17:33:29

What is the correct way to send/receive files with HTTP requests over a slow connection?

The essence of the question is this: there are mobile clients who can sit on 2G, which, moreover, sometimes breaks.
Clients send small files (up to a megabyte) to the server and also receive them. All through HTTP requests.
I want to make requests in any direction resumable if the connection is broken, and I also want to show a more or less accurate progress bar.
I read about the HTTP Range header, but it seems to work only when downloaded from the server.
Is there an analogue of HTTP range for a POST request from the client side? Those. the client could put a Range header indicating that it is sending only part of the data, and make several requests in turn until everything is downloaded.
Maybe I'm not digging there at all and there are better solutions in 2017?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2017-11-03
@Taraflex

You can get the contents of the file on the client as an ArrayBuffer
https://developer.mozilla.org/ru/docs/Web/API/File... we
cut the resulting buffer into pieces with handles and send it with several requests (in addition to simple ajax, you can try to use websocket or webrtc )
https://learn.javascript.ru/xhr-onprogress

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question