Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Curl data binary option, out of memory

I am tyring to use curl to upload data. I need to upload the binary data.

Unfortunately i think curl loads the file binary into the memory first so for large files this is an issue. The system I am using has a very small amount of memory available and therefore even a file that is 8mb big is struggling and I get:

curl: option --data-binary: out of memory
curl: try 'curl --help' for more information

I have tried the chunked option, and that doesn't seem to work either.

So far this is what I am trying:

curl --insecure -v --max-time 1200 ... --data-binary @/tmp/sd/record/....mp4 --header Transfer-Encoding: chunked -o UPLOAD_TOKEN -D Media_Binary_Data https://....upload

Is there a way that I can prevent the file from loading the binary into the memory or force it to store this data in an sd card and read it from there?

like image 443
mfaiz Avatar asked Jan 27 '26 00:01

mfaiz


1 Answers

The reason for the out of memory is that --data and its friends all read the data into memory before sending it off to the server. You can work around that easily by doing -T -X POST, but I still believe you went wrong already in your initial -F test.

From: https://github.com/curl/curl/issues/1385

like image 193
Poshi Avatar answered Jan 29 '26 13:01

Poshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!