Reputation: 13996
How to insert the contents of a file in the middle of text in
--data-binary
usingcurl
?
I want to insert the contents of a binary file in the middle of --data-binary
, e.g. --data-binary='abc@FILEdef'
, and have curl
update the Content-Length
header accordingly.
However, the preceding example doesn't seem to work.
Any ideas on how to accomplish this?
The only way I can think of is to prepend/append the text to the FILE
beforehand, but this is rather cumbersome for large amounts of text.
Upvotes: 0
Views: 106
Reputation: 58124
One way to accomplish this without having to generate a temporary file first, is to simply generate the POST data for curl on stdin. For example:
(printf "beginning\n" && cat $filename && printf "trailer\n") | curl --data-binary @- $url
Upvotes: 1