Answer the question
In order to leave comments, you need to log in
How to send a big file(audio or video) to server from android application right?
Let's say we have a server in php and a client in Java. I need the user to be able to send a file larger than 50 mb to the server via service, but in such a way that if the phone turns off or the Internet is temporarily unavailable, the download will pause and start from the same place. Plus, a description will be sent along with this file and everything will be saved together in the MySQL database. That is, I need to implement sending files to the server in the same way as implemented in Instagram or YouTube. But I have never done this before and I don’t know where to start and what is needed for this.
Answer the question
In order to leave comments, you need to log in
Adult developers use headers. Nobody restricts you from using the Content-Range header in a request.
I'm sorry, let me use the httpie syntax.
POST "/upload/"
Content-Type:[MEDIA_TYPE]
Content-MD5:[BASE64_MD5_FILE]
Content-Range: bytes [FROM_BYTES]-[TO_BYTES]/[FILE_SIZE]
[email protected]
One endpoint. Without boilerplate from three different requests.
bytes 0-? : creates a file, I would recommend creating with the name md5;
bytes? -? : write to file
bytes ? - total_size : write to file, checksum check, rename.
Chunk size = channel width >> 1
Implement the following api
/api/continuousupload - accepts multipart/form-data
/api/continuousuploadcreate - creates a long upload on the server
/api/continuousuploadinfo - sends information by chunk
On the client
1. /api/continuousuploadcreate - create an upload server returns id
2. beat send the file into chunks, let it be 2 megabytes each, via /api/continuousupload
3. the server writes the position of the pointer in the meta file and writes the byte stream received from /api/continuousupload
4. When the connection is broken, the server sends exactly the recorded data via /api/continuousuploadinfo the client sends the chunk starting from the position
Accordingly, both the server and the client need to calculate checksums during transmission.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question