cURL
We would not recommend to use the cURL integration for production, but it can be convenient for a quick test when you don't have an SDK lying around.
Install
brew install curl jq || sudo apt install curl jq
Example
The Transloadit-Client header identifies cURL and its installed version to help with debugging.
(
set -euo pipefail
# Prerequisites: brew install curl jq || sudo apt install curl jq
# To avoid tampering, use Signature Authentication
echo '{
"template_id": "YOUR_TEMPLATE_ID",
"auth": {
"key": "YOUR_TRANSLOADIT_KEY"
},
"steps": {}
}' | curl --fail \
--request POST \
--header "Transloadit-Client: curl:$(curl --version | awk 'NR == 1 {print $2}')" \
--form 'params=<-' \
--form myfile1=@./joe-gardner-149699.jpg \
https://api2.transloadit.com/assemblies | jq
)
Signed request
With Signature Authentication required, every request needs a signature for its exact params. The transloadit CLI that ships with @transloadit/node adds your Auth Key and an expiry, then prints the signed params and its signature. It reads your credentials from the environment.
These signing examples use SHA-256, which Auth Keys with Smart CDN signing enabled accept. If your Auth Key uses another Signature algorithm, match it in --algorithm, the OpenSSL digest, and the signature prefix.
(
set -euo pipefail
export TRANSLOADIT_KEY="YOUR_TRANSLOADIT_KEY"
export TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
signed=$(echo '{"template_id": "YOUR_TEMPLATE_ID"}' | npx -y @transloadit/node signature --algorithm sha256)
curl --fail \
--request POST \
--form-string "params=$(jq -r .params <<<"$signed")" \
--form-string "signature=$(jq -r .signature <<<"$signed")" \
--form myfile1=@./joe-gardner-149699.jpg \
https://api2.transloadit.com/assemblies | jq
)
Without Node.js, compute the same signature with OpenSSL: an HMAC-SHA256 of the exact params string, keyed with your Auth Secret.
(
set -euo pipefail
export TRANSLOADIT_KEY="YOUR_TRANSLOADIT_KEY"
export TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
# One hour from now, in UTC (BSD/macOS date first, then GNU date)
format='%Y/%m/%d %H:%M:%S+00:00'
expires=$(date -u -v+1H "+$format" 2>/dev/null || date -u -d '+1 hour' "+$format")
params=$(jq -nc --arg key "$TRANSLOADIT_KEY" --arg expires "$expires" \
'{auth: {key: $key, expires: $expires}, template_id: "YOUR_TEMPLATE_ID"}')
hmac=$(printf '%s' "$params" \
| openssl dgst -sha256 -hmac "$TRANSLOADIT_SECRET" | awk '{print $NF}')
signature="sha256:$hmac"
curl --fail \
--request POST \
--form-string "params=$params" \
--form-string "signature=$signature" \
--form myfile1=@./joe-gardner-149699.jpg \
https://api2.transloadit.com/assemblies | jq
)
Send params as a form field, as these examples do. The API does not accept a JSON request body.