Skip to content

Instantly share code, notes, and snippets.

@wjkoh
Last active April 22, 2024 02:37
Show Gist options
  • Save wjkoh/32b2aa94a2ec90424eb7f8acdca6b302 to your computer and use it in GitHub Desktop.
Save wjkoh/32b2aa94a2ec90424eb7f8acdca6b302 to your computer and use it in GitHub Desktop.
cURL: How to convert a file to a Base64 encoded string and send it as JSON to HTTP
#!/usr/bin/env bash
BASE64=$(base64 -i yann-lecun_resize.jpg)
curl --request POST \
--url http://localhost:8080/v1/images \
--header 'Content-Type: application/json' \
--data '{ "image": "'${BASE64}'" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment