Asset preview and upload

This describes the endpoints for getting a preview of an asset, for example images, and for uploading new assets to the CMS.

GET /asset/preview

Retrieve a preview of an asset from the CMS. The CMS must return the binary result of the asset, the image for example, with the correct MIME type for the asset.

Parameters

context (Required)

The context from which the document was loaded.

Parameter type

query

context

parameter

required

type

description

editSessionToken

required

string

Uniquely identifies the instance of Fonto Editor. See Invocation of Fonto Editor for details.

documentId

required

string

The id of the current document.

id (Required)

The id of the asset to retrieve.

Parameter type

query

Type

string

variant (Required)

The preferred preview variant to retrieve. Thumbnail dimension being 128x128 pixels fixed size and web being 1024x1024 pixels maximum.

Parameter type

query

Type

string

Possible values

  • thumbnail

  • web

Responses

Status

Reason

200

The requested asset preview is returned successfully.

304

The file has not been changed. Should be handled by browser caching.

403

The user is not authorized to retrieve the asset.

404

The asset does not exist in the CMS.

500

Any error in the 500 range indicates a problem with the CMS.

Examples

Request

context

JavaScript

{
	"editSessionToken": "EF091CD9-DC7A-4F91-9964-21CAF0DC3DCE",
	"documentId": "74257961-EDE3-4180-AF17-0A435EE8FB7B"
}

id

7F3D8CDA-948A-4F01-9019-76372C68296D

variant

thumbnail

context

JavaScript

{
	"editSessionToken": "EF091CD9-DC7A-4F91-9964-21CAF0DC3DCE",
	"documentId": "74257961-EDE3-4180-AF17-0A435EE8FB7B"
}

id

7F3D8CDA-948A-4F01-9019-76372C68296D

variant

web

POST /asset

Fonto Editor will issue a multipart/form-data request containing the uploaded file and the metadata to associate with the file. The binary data of the file is always stored in the file field.

Parameters

request (Required)

The body of the request. This will be send as a Multipart/form-data post, using 'request' as it's name.

Parameter type

Multipart body part

Content type

application/json

Content disposition

form-data

Name

request

body

parameter

required

type

description

context

required

Context

The context from which the upload was invoked.

type

required

string

The type of content to upload. The only reserved type is 'document'. For example this could be image, video, audio or any other editor specific type.

folderId

optional

string

The id of the folder to upload to, if none is specified, the root folder is meant.

metadata

optional

Metadata

The metadata to assosiate with the asset.

Context

parameter

required

type

description

editSessionToken

required

string

Uniquely identifies the instance of Fonto Editor. See Invocation of Fonto Editor for details.

documentId

required

string

The id of the current document.

file (Required)

The binary data of the asset as a multipart/form-data post, using 'file' as it's name. The original filename is also included in this data.

Parameter type

Multipart body part: File (A native browser form data File part)

Content disposition

form-data

Name

file

Responses

Status code 201

The asset is successfully uploaded to the CMS.

body

parameter

required

type

description

id

required

string

The identifier of the uploaded asset.

label

required

string

The label to use for displaying the resource in the asset browser.

type

required

string

The type of document, image, file or unknown.

metadata

optional

Metadata

The metadata of the asset.

Status code 400

Fonto Editor provided invalid or insufficient information to upload the asset.

Status code 403

The user is not authorized to upload here.

Status code 404

The folderId does not exist in the CMS.

Status code 500

Any error in the 500 range indicates a problem with the CMS.

Examples

Request

request

JavaScript

{
	"context": {
		"editSessionToken": "EF091CD9-DC7A-4F91-9964-21CAF0DC3DCE",
		"documentId": "74257961-EDE3-4180-AF17-0A435EE8FB7B"
	},
	"type": "image"
}

file

Content-Disposition: form-data; name="file"; filename="example-image.png"Content-Type: image/png
<Image data>

Response

Other

{
	"id": "7F3D8CDA-948A-4F01-9019-76372C68296D",
	"label": "example-image.png",
	"type": "image"
}