prepare_image_upload
Step 1 of 2 for adding an image (PNG / JPEG / GIF / WebP) to the current team media library. This tool does NOT receive image bytes — it returns a short-lived presigned URL you upload the file to directly, so even large images never pass through this conversation. Workflow: (1) save the image to a local temp file; (2) if the file is larger than 5MB, compress / downscale it to 5MB or less FIRST (e.g. sips -Z 2048 in.png --out out.jpg on macOS, or magick in.png -resize "2048x2048>" -quality 82 out.webp) — uploads over 5MB are rejected; (3) call this tool with filename, mimeType and (optionally) fileSize; (4) HTTP PUT the temp file to the returned uploadUrl with the matching Content-Type header, e.g. curl -X PUT --upload-file <file> "<uploadUrl>" -H "Content-Type: image/png"; (5) call finalize_image_upload with the returned key; (6) delete the temp file. Max 5MB after compression. Only image/png, image/jpeg, image/gif and image/webp are accepted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileSize | No | Optional file size in bytes (of the file you will actually upload, after any compression). If provided it is checked against the 5MB cap and the team storage quota up front; the authoritative check still runs in finalize_image_upload against the actual uploaded size. | |
| filename | Yes | Original filename for admin display / download, e.g. "cover.png". | |
| mimeType | Yes | Image MIME type. Must be one of image/png, image/jpeg, image/gif, image/webp. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Staging object key to pass to finalize_image_upload | |
| expiresIn | No | Seconds until the presigned URL expires | |
| uploadUrl | No | Presigned PUT URL — upload the bytes here, then call finalize_image_upload | |
| requiredContentType | No | Content-Type header the PUT must send, or R2 rejects it |