I want to send a large video to the server but I have to split the video into multiple parts and send each of the parts to be sent consecutively. Which approach I must use? Note: I use ktor client to connect to the server
Asked
Active
Viewed 211 times
0
-
The best approach would be to split the file in multiple parts and send those consecutively. – blackapps Dec 14 '22 at 09:41
-
@blackapps Do you have any kotlin sample code? – Saeed Noshadi Dec 14 '22 at 10:27
-
Do you want to make an HTTP request for each part or send parts in one request? – Aleksei Tirman Dec 14 '22 at 10:54
-
@AlekseiTirman I want an HTTP request for each part, The chunks are sent in sequential order, and the next chunk can be sent to the server according to the success of the previous chunk. – Saeed Noshadi Dec 14 '22 at 11:05
-
You can send a request body as a `ByteArray` of a video part https://ktor.io/docs/request.html#body and a header indicating what video is being uploaded. – Aleksei Tirman Dec 14 '22 at 11:28
-
@AlekseiTirman could you please write a sample code here? – Saeed Noshadi Dec 14 '22 at 11:44
-
It would be better if you try to make some solution and then ask specific questions about problems that you have. – Aleksei Tirman Dec 15 '22 at 08:16
-
@AlekseiTirman you are right, but I don't have any idea to do that – Saeed Noshadi Dec 15 '22 at 08:38
-
Then start by reading the documentation and trying to send simple POST requests with a binary body and receiving them on a server. – Aleksei Tirman Dec 15 '22 at 09:20
-
@AlekseiTirman I know about POST requests in ktor but i don't know about how can i split video file to multiple parts – Saeed Noshadi Dec 15 '22 at 09:29
-
Here is an idea of how to do it https://stackoverflow.com/a/22575658/13963150 – Aleksei Tirman Dec 15 '22 at 09:42