What does it do?
Creates assets. Uploads and downloads originals, previews, and thumbnails.
Log in requirement
All calls require an authenticated session, as described in Assets Server REST API - login.
Create Asset API
|
|
Creates an asset 'placeholder': the asset record with its metadata. The file itself is uploaded afterwards to the returned uploadUrl.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| assetPath | string |
Full path of the new asset. Required. |
/Demo Zone/Images/my-photo.jpg |
| autoRename | boolean |
When true (default), an incremental number is appended to the file name when an asset already exists on assetPath. Optional. |
FALSE |
| metadata | object |
Metadata field names and values to set on the new asset. Optional. |
{ "description": "My uploaded photo" } |
| metadataToReturn | array of strings |
Metadata fields to return in the metadata property of the response. Optional. When not specified, no metadata fields are returned. |
["id", "filename", "assetPath"] |
Result
| Field | Type | Description |
|---|---|---|
| id | string | Unique ID of the created asset. |
| metadata | object | The metadata fields requested with metadataToReturn. |
| permissions | string | The current user's permissions on the asset. |
| thumbnailUrl | string | URL for downloading the asset's thumbnail. |
| previewUrl | string | URL for downloading the asset's preview. |
| originalUrl | string | URL for downloading the asset's original file. |
| uploadUrl | string | URL to which the asset's file can be uploaded. |
Examples
Request
curl -X POST "https://yourserver.com/api/asset" \
-H "Authorization: Bearer <authToken>" \
-H "Content-Type: application/json" \
-d '{
"assetPath": "/Demo Zone/Images/my-photo.jpg",
"autoRename": true,
"metadata": {
"description": "My uploaded photo"
},
"metadataToReturn": ["filename", "assetPath"]
}'Response
{
"id": "EXc_g0Bw4W7BPZy0h8BFOG",
"metadata": {
"id": "EXc_g0Bw4W7BPZy0h8BFOG",
"filename": "my-photo.jpg",
"assetPath": "/Demo Zone/Images/my-photo.jpg"
},
"permissions": "VPWUMERXCGD",
"thumbnailUrl": null,
"previewUrl": null,
"originalUrl": null,
"uploadUrl": "https://assets.example.com/api/asset/EXc_g0Bw4W7BPZy0h8BFOG/original?createVersion=false&requestSecret=eyJhbGciOiJIUzI1NiJ9..."
}Uploading files
Step 1. Create the asset using the Create asset API as described above.
Step 2. Send the file data to the uploadUrl. The HTTP method determines how the file data is handled:
Note: The uploadUrl is valid for 4 hours.
| Method | Content type | Behavior |
|---|---|---|
| PUT | application/octet-stream |
The file data is streamed: it is passed on to the storage in chunks as it arrives. Recommended, especially for large files. |
| POST | multipart/form-data |
The complete file is first received and buffered by the server before it is stored. |
Upload original API - streaming upload
|
|
Uploads a file for an asset placeholder or replaces an existing asset's original.
The data is streamed; it is not buffered in memory first.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| id | string |
ID of the asset. Required. |
EXc_g0Bw4W7BPZy0h8BFOG |
| createVersion | boolean |
When true (default) and the asset already has a file, a new version is created. Optional. |
FALSE |
Result
The updated asset object:
| Field | Type | Description |
|---|---|---|
| id | string | Unique ID of the asset. |
| permissions | string | The current user's permissions on the asset (see Permissions). |
| thumbnailUrl | string | Download URL of the thumbnail. |
| previewUrl | string | Download URL of the preview. |
| originalUrl | string | Download URL of the original file. |
Example
curl -X PUT "https://assets.example.com/api/asset/EXc_g0Bw4W7BPZy0h8BFOG/original?createVersion=false&requestSecret=eyJhbGciOiJIUzI1NiJ9..." \
-H "Content-Type: application/octet-stream" \
-H "Content-Length: 123456" \
--upload-file /path/to/my-photo.jpgUpload original API - multipart upload
|
|
Uploads a file for an asset placeholder or replaces an existing asset's original.
The complete file is buffered by the server before it is stored.
Note: For large files, the streaming upload is preferred..
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| id | string |
ID of the asset. Required. |
EXc_g0Bw4W7BPZy0h8BFOG |
| createVersion | boolean |
When true (default) and the asset already has a file, a new version is created. Optional. |
FALSE |
| file | file |
The file data, multipart/form-data encoded. Required. |
Result
Same as for the Streaming upload API.
Example
curl -X POST "https://assets.example.com/api/asset/EXc_g0Bw4W7BPZy0h8BFOG/original" \
-H "Authorization: Bearer <authToken>" \
-F "file=@/path/to/my-photo.jpg"Get asset API
|
|
Returns the asset with the matching ID.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| id | string |
Asset identifier. Required. |
EXc_g0Bw4W7BPZy0h8BFOG |
Result
| Field | Type | Description |
|---|---|---|
| id | string | Unique ID of the asset. |
| metadata | object | All metadata fields of the asset that are visible to the current user. |
| permissions | string | The current user's permissions on the asset (see Permissions). |
| thumbnailUrl | string | Download URL of the thumbnail. |
| previewUrl | string | Download URL of the preview. |
| originalUrl | string | Download URL of the original file. |
Search assets API
|
|
Searches for assets.
The query uses the same syntax as the Search API.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| q | string |
The search query. Required. |
name:my-photo* |
| from | number |
The offset from the first result. Optional. Default is 0. |
0 |
| size | number |
The maximum amount of hits to be returned. Optional. Default is 10. |
50 |
Result
| Field | Type | Description |
|---|---|---|
| total | number | Total number of assets matching the query. |
| hits | array | The matching assets. |
Examples
Request
curl "https://yourserver.com/api/asset/search?q=filename:my-photo.jpg&size=5" \
-H "Authorization: Bearer <authToken>"Response
{
"total": 1,
"hits": [
{
"id": "EXc_g0Bw4W7BPZy0h8BFOG",
"thumbnailUrl": "https://yourserver.com/thumbnail/EXc_g0Bw4W7BPZy0h8BFOG/...",
"previewUrl": "https://yourserver.com/preview/EXc_g0Bw4W7BPZy0h8BFOG/...",
"originalUrl": "https://yourserver.com/file/EXc_g0Bw4W7BPZy0h8BFOG/my-photo.jpg",
"highlightedText": null,
"metadata": {
"filename": "my-photo.jpg",
"assetPath": "/Demo Zone/Images/my-photo.jpg",
"extension": "jpg",
"mimeType": "image/jpeg"
}
}
]
}Download APIs
|
|
Downloads the asset's original file, thumbnail or preview.
Note: When the thumbnail or preview has not been generated yet, it is generated on the fly.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| id | string |
ID of the asset. Required. |
EXc_g0Bw4W7BPZy0h8BFOG |
Signed URL APIs
|
|
Returns time-limited signed URLs for the originals, previews or thumbnails of the given assets.
A signed URL can be used to download the file without further authentication.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| ids | string |
Comma-separated list of asset IDs. Required. |
EXc_g0Bw4W7BPZy0h8BFOG,6He5UybK4EV8F0sfuAga_X |
| validFor | number |
Amount of seconds during which the URL is valid. Specify -1 to obtain a URL which is valid forever. Optional. Default is 600. |
3600 |
Result
An array of objects:
| Field | Type | Description |
|---|---|---|
| assetId | string | ID of the asset. |
| signedUrl | string | The signed URL. |
Example
curl "https://yourserver.com/api/asset/EXc_g0Bw4W7BPZy0h8BFOG,6He5UybK4EV8F0sfuAga_X/signed-original-url?validFor=3600" \
-H "Authorization: Bearer <authToken>"[
{
"assetId": "EXc_g0Bw4W7BPZy0h8BFOG",
"signedUrl": "https://assets.example.com/file/EXc_g0Bw4W7BPZy0h8BFOG/*/my-photo.jpg?requestSecret=eyJhbGciOiJIUzI1NiJ9..."
}
]Signed image rendition URL API
|
|
Returns time-limited signed URLs for image renditions that are generated from the originals of the given assets with the requested settings.
Parameters
| Name | Type | Description | Example |
|---|---|---|---|
| ids | string |
Comma-separated list of asset IDs. Required. |
EXc_g0Bw4W7BPZy0h8BFOG |
| validFor | number |
Amount of seconds during which the URL is valid. Specify -1 to obtain a URL which is valid forever. Optional. Default is 600. |
3600 |
| format | string |
Requested image rendition format. Valid values are jpg, png, or tiff. Required. |
jpg |
| scale | number |
Scales the width and height of the rendition relative to the original size. The scale is in percentages from 1 to 100. If used in combination with maxWidth or maxHeight, the image will be scaled with a maximum size. Optional. |
50 |
| maxWidth | number |
Sets the maximum width of the rendition. The aspect ratio will always remain the same. If the original asset fits within the supplied dimensions, the original width and height will be used for generating the rendition. Optional. |
1024 |
| maxHeight | number |
Sets the maximum height of the rendition. The aspect ratio will always remain the same. If the original asset fits within the supplied dimensions, the original width and height will be used for generating the rendition. Optional. |
768 |
| ppi | number |
The pixels per inch / dots per inch. When not set, the original PPI / DPI value of the asset will be used. Optional. |
72 |
| embedMetadata | boolean |
When set to true, the metadata embedded in the original asset will be embedded in the generated rendition. Note that for certain file types, the embedding of metadata is not supported. Optional. By default the original metadata is not embedded. |
TRUE |
| embedColorProfile | boolean |
When set to true, the color profile that is used to generate the rendition is included. Optional. Default is false. |
TRUE |
| compression | string |
TIFF compression type, applicable when format is tiff. Allowed values:
Optional. |
LZW |
| quality | number |
JPEG compression, applicable when format is jpg. The quality is defined as a value from 1 to 100. Optional. |
90 |
| watermarked | boolean |
When set to true, a watermark is applied to the rendition. Note: A watermark needs to be configured in the server configuration. Optional. Default is false. |
TRUE |
| background | string |
Sets the background color (hex color code) for transparent images. If not specified, the output of PNG and TIFF images will be transparent. Optional. |
#ffffff |
| cropWidth | number |
Sets the width (in pixels) to which the image should be cropped. Optional. |
800 |
| cropHeight | number |
Sets the height (in pixels) to which the image should be cropped. Optional. |
600 |
| cropOffsetX | number |
Sets the crop x offset in pixels (from the top left corner). Optional. |
100 |
| cropOffsetY | number |
Sets the crop y offset in pixels (from the top left corner). Optional. |
100 |
Result
Same as for the Signed URL API.
Permissions
The permissions field returned by several APIs is a string in which every position represents a permission of the current user on the asset.
A permission that is not granted is shown as -.
| Character | Permission |
|---|---|
| V | View |
| P | View preview |
| W | View non-watermarked |
| U | Use original |
| M | Edit metadata |
| E | Edit |
| R | Rename |
| X | Move |
| C | Create |
| G | Create nested collection |
| D | Delete |
Comments
0 comments
Please sign in to leave a comment.