Last active
May 17, 2019 18:08
-
-
Save vbarbarosh/fd291d1a26fc7808e11981556afc768c to your computer and use it in GitHub Desktop.
shell_curl_post_multipart_detailed – POST as multipart/form-data with curl https://codescreens.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# POST as multipart/form-data with curl | |
# https://curl.haxx.se/docs/manpage.html | |
# Send name=value (`<`, `@`, and `;` in value has special meaning) | |
curl https://echo.vbarbarosh.com -F 'name=value' | |
# Read content from file `body.txt` | |
curl https://echo.vbarbarosh.com -F 'name=<body.txt' | |
# Read content from file `body.txt`, add filename="body.txt" parameter | |
curl https://echo.vbarbarosh.com -F '[email protected]' | |
# Add `filename=hello.txt` parameter | |
curl https://echo.vbarbarosh.com -F 'name=value;filename=hello.txt' | |
# Add `Content-Type: text/foo` header | |
curl https://echo.vbarbarosh.com -F 'name=value;type=text/foo' | |
# Add `foo1: bar1` header | |
curl https://echo.vbarbarosh.com -F 'name=value;headers=foo1:bar1' | |
# Add `foo1: bar1`, `foo2: bar2` headers | |
curl https://echo.vbarbarosh.com \ | |
-F 'name=value;headers=foo1:bar1;headers=foo2:bar2' | |
# Read headers from `headers.txt` | |
curl https://echo.vbarbarosh.com -F 'name=value;[email protected]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment