Media and image uploads
Uploads do not pass through the API. You ask for a presigned URL, you PUT the bytes at object storage, and you tell us it finished. Three requests, and the file never touches our bandwidth or our memory.
Endpoints
| Method | Path | What it does | Auth |
|---|---|---|---|
| POST | /v1/blog/media | Record a file and get an upload URL | Session or agent |
| POST | /v1/blog/media/{id}/complete | Confirm the upload finished | Session or agent |
| GET | /v1/blog/media | List media | Key or session |
| PATCH | /v1/blog/media/{id} | Set the alternative text | Session or agent |
| DELETE | /v1/blog/media/{id} | Delete media | Session or agent |
The three requests
Ask for a URL
Send the filename, the media type, the size and a SHA-256 of the bytes. You get back a media row with
uploadStatus: "pending"and a presigned URL that expires shortly.curl -X POST https://api.cmskite.com/v1/blog/media \ -H "authorization: Bearer $ACCESS_TOKEN" \ -H "x-tenant-id: $WORKSPACE_ID" \ -H "x-project-id: $PROJECT_ID" \ -H 'content-type: application/json' \ -d '{ "filename": "rotterdam.jpg", "mimeType": "image/jpeg", "sizeBytes": 481223, "checksumSha256": "9f86d0818…", "width": 1600, "height": 900 }'PUT the bytes
Straight at object storage, from wherever the file is — including the visitor’s browser. No credential of yours is involved; the presigned URL is the authorisation, and it is narrow and short-lived.
curl -X PUT "$UPLOAD_URL" \ -H 'content-type: image/jpeg' \ --data-binary @rotterdam.jpgConfirm it
The media row flips to
readyand becomes visible to a project key. Until then it is not served: a half-finished upload is not content.curl -X POST https://api.cmskite.com/v1/blog/media/$MEDIA_ID/complete \ -H "authorization: Bearer $ACCESS_TOKEN" \ -H "x-tenant-id: $WORKSPACE_ID" \ -H "x-project-id: $PROJECT_ID"
The same file twice is the same file
Media is content-addressed by its checksum within a project. Re-uploading the same logo for the fortieth time returns the row you already have instead of making a fortieth copy — which is the most common thing a media library is asked to do, and makes uploading idempotent for free.
What makes the image worth having
An image is roughly always the heaviest thing on an article page, and three fields decide whether it helps the page or holds it back. All three are yours to send, because the bytes never pass through us — we cannot open the file to work them out.
filenamebecomes the last part of the stored object’s address, sanitised and made unique. Name it after the post —porto-harbour-at-dawn.webpis what an image search reads;IMG_4821.JPEGis not.widthandheightare the intrinsic pixel size. Send them and a page can reserve the space before the bytes land; leave them out and the article reflows when the image arrives, which is the layout shift a page is scored on.altTextis the sentence read aloud in place of the picture, and the only description of it a search engine can read. Set it withPATCH /v1/blog/media/{id}— usually after the upload, since it is written while looking at the image. An empty value means the image is decorative and should be skipped, which is a real answer, not a missing one.
All three come back on featuredMedia when you read a post, so a page can render <img src alt width height> from one response with no second request.
What is accepted
- Images and documents. A
text/htmlupload is refused: a file served from your domain that can run script is not a media library, it is an XSS vector. - A malformed checksum or a negative size is a 400 before any URL is issued.
- Storage is metered per plan.
blog.media.storage_bytesis the capability; your dashboard shows what you have used. - An upload that is never confirmed is reaped. A presigned URL that nobody used costs you nothing.
- A picture is removed when the last post using it stops — whether that post was deleted, or its
featuredMediaIdwas changed or cleared. Never while another post still points at it: media is shared by content hash, so one picture can belong to many posts.
403 ENTITLEMENT_REQUIRED naming blog.media.enabled, so a client can tell this apart from a bug.