send base64 encoded image using curl

@muru is correct, however if you are trying to send a json encoding your base64 data may be too large for the command line and you may prefer something like this:

(echo -n '{"image": "'; base64 ~/Pictures/1.jpg; echo '"}') |
curl -H "Content-Type: application/json" -d @-  http://some/url/ 

The -X POST is implied by -d.


Bash doesn't expand in single quotes. '{"image" : $( base64 ~/Pictures/1.jpg )}' gets sent as-is. Instead, try:

'{"image" : "'"$( base64 ~/Pictures/1.jpg)"'"}'

(Exit the opening quote before doing command substitution then open a quote again.)