Upload an image, an attachment or a font into a change set
Stores the file in the blob store under its SHA-256 and answers with reference (sha256:<hash>), for an image or attachment block's asset in a module's working copy; nothing is committed to Git (the module commits the reference at a save point). Send it as multipart/form-data with one file part named file and nothing else; its file name is kept (made a valid file name: fileName). The part's Content-Type is ignored. An image (kind=image, the default) is recognised from the bytes: PNG or JPEG; SVG and anything else is 422 unsupported-image-type; at most CCMS_MAX_UPLOAD_BYTES (default 10 MiB). An attachment (kind=attachment) may be any type: its media type is decided from the bytes and the file name's extension (bytes showing HTML, SVG, an executable or a script win over any name); dangerous types (HTML, SVG, executables, installers, scripts) and what the CCMS_ATTACHMENT_TYPES_* settings refuse are 422 unsupported-attachment-type (meta.contentType, meta.extension, meta.reason); at most CCMS_MAX_ATTACHMENT_BYTES (default 50 MiB). A font (kind=font, for a page design's fonts) is recognised from its structure, never its name: a TrueType or OpenType font (font/ttf, font/otf), WOFF or WOFF2 (font/woff, font/woff2) whose tables are all within the file and which has a family name; a collection or anything else is 422 unsupported-font-type (meta.accepted, meta.reason: not-a-font or malformed); at most CCMS_MAX_FONT_BYTES (default 10 MiB) and 100 fonts per change set. A larger file is 422 too-large (meta.max), and reading stops there. Only the change set's author, while it is a draft (409 invalid-state otherwise, as for locks and saves), and at most 1,000 files per change set (409 too-many-uploads); with a storage limit set (CCMS_STORAGE_LIMIT_BYTES), a file that would take the installation past it is 409 storage-limit-reached (meta.limit), nothing is stored and the refusal is audited (storage.upload-refused): 403 for anyone else who holds content.read.draft, 404 for anyone who does not. Recorded with an asset.upload audit event. The same file again is 200 with the first upload, and nothing new is stored or audited. Needs the content.edit permission.
bearerAuthorizationBearer <JWT>A service account's token (ccms_sat_…, issued by POST /service-accounts/{id}/tokens), or, for local use and demo mode, the server's shared CCMS_API_TOKEN.
changeSetId*stringThe change set’s ID (a UUID). One that names no change set, malformed or not, is 404.
uuidkind?stringimage (default): a PNG or JPEG for an image block. attachment: a file of any type the settings take, for an attachment block. font: a TrueType, OpenType, WOFF or WOFF2 font for a page design.
"image""attachment""font"X-Ccms-Request?stringRequired (any non-empty value) with a body of type multipart/form-data: a cross-site form cannot send it. Not needed with application/vnd.api+json.
X-Ccms-User?stringDemo mode only (CCMS_AUTH_MODE=demo): the user ID to act as. The bearer token is still required; without demo mode the header is refused (400).
multipart/form-data- body
file*unknownThe change set holds this image already: the first upload, unchanged.
application/vnd.api+json- response
data*id is <changeSetId>/<sha256>. The author previews it at GET /change-sets/{changeSetId}/assets/{hash}; once a module the reader may see refers to it, GET /assets/{hash} serves it.
curl -X POST 'http://localhost:3000/change-sets/497f6eca-6276-4993-bfeb-53cbbbba6f08/assets' \ -F 'file=null'{ "data": { "type": "ChangeSetAsset", "id": "string", "attributes": { "reference": "string", "contentType": "string", "size": 0, "fileName": "string", "uploadedBy": { "kind": "user", "id": "string" }, "uploadedAt": "2019-08-24T14:15:22Z" }, "relationships": { "changeSet": { "data": { "type": "ChangeSet", "id": "string" } } } }}