This guide shows how to upload a file using the Composio API now that storage is on Cloudflare R2. You will receive a pre‑signed PUT URL, upload the file to that URL, then reference the returned key when executing a tool.
gmail, tool GMAIL_SEND_EMAIL)Call the Composio API to create an upload request. The response now looks like this (example):
{
"id": "1e9e4..",
"key": "44117/gmail/GMAIL_SEND_EMAIL/request/2...",
"newPresignedUrl": "[https://temp.4d4](https://temp.4d4f16c61d89ec64e760039c4ec50717.r2.cloudflarestorage.com/44137/gmail/GMAIL_SEND_EMAIL/request/2340b0520542f1e12389eac4e487bb0d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=feb4b92dda89e2fa640b62ba48a641d2%2F20251030%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251030T134555Z&X-Amz-Expires=86400&X-Amz-Signature=5c3298af26da96f81bb32b68bffbc00c8458cb21cfce420c2e302c068bf9015b&X-Amz-SignedHeaders=host)...",
"type": "new"
}
Notes:
Use HTTP PUT to upload your file to newPresignedUrl. Set Content-Type to your file’s MIME type. Content-MD5 is optional unless enforced by your setup.
FILE_PATH="/path/to/file.pdf"
MIME="application/pdf"
URL="${NEW_PRESIGNED_URL_FROM_STEP_1}"
curl -X PUT "$URL" \
-H "Content-Type: $MIME" \
--data-binary @"$FILE_PATH"
If you need to include an MD5 checksum (optional):
MD5_B64=$(openssl dgst -md5 -binary "$FILE_PATH" | openssl base64)
curl -X PUT "$URL" \
-H "Content-Type: $MIME" \
-H "Content-MD5: $MD5_B64" \
--data-binary @"$FILE_PATH"
Expected result: