Asset instances
Type Definitions
Asset #
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sys |
Meta.Sys | Standard system metadata with additional asset specific properties
Properties
|
||||||||||||||||||||||||||||||||||||
fields |
Object | Object with content for each field
Properties
|
||||||||||||||||||||||||||||||||||||
toPlainObject() |
function | Returns this Asset as a plain JS object |
- Source:
AssetCollection #
Properties:
Name | Type | Description |
---|---|---|
total |
number | |
skip |
number | |
limit |
number | |
items |
Array.<Asset.Asset> | |
toPlainObject() |
function | Returns this Asset collection as a plain JS object |
- Source:
Methods
(static) archive() → {Promise.<Asset>} #
Archives the object
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
- Source:
Example
asset.archive()
.then(asset => console.log(asset.sys.archivedVersion))
(static) delete() → {Promise} #
Deletes this object on the server.
Returns:
Promise for the deletion. It contains no data, but the Promise error case should be handled.
- Type:
- Promise
- Source:
Example
asset.delete()
.catch(err => console.log(err))
(static) isArchived() → {boolean} #
Checks if asset is archived. This means it's not exposed to the Delivery/Preview APIs.
Returns:
- Type:
- boolean
- Source:
(static) isDraft() → {boolean} #
Checks if the asset is in draft mode. This means it is not published.
Returns:
- Type:
- boolean
- Source:
(static) isPublished() → {boolean} #
Checks if the asset is published. A published asset might have unpublished changes (@see {Asset.isUpdated})
Returns:
- Type:
- boolean
- Source:
(static) isUpdated() → {boolean} #
Checks if the asset is updated. This means the asset was previously published but has unpublished changes.
Returns:
- Type:
- boolean
- Source:
(static) processForAllLocales(options) → {Promise.<Asset>} #
Triggers asset processing after an upload, for the files uploaded to all locales of an asset.
Parameters:
Name | Type | Description |
---|---|---|
options |
object | Additional options for processing |
Throws:
-
If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.
- Type
- AssetProcessingTimeout
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
Properties:
Name | Type | Description |
---|---|---|
options.processingCheckWait |
number | Time in milliseconds to wait before checking again if the asset has been processed (default: 500ms) |
options.processingCheckRetries |
number | Maximum amount of times to check if the asset has been processed (default: 5) |
- Source:
Example
asset.processForAllLocales()
.then(asset => console.log(asset.fields.file['en-US'].url, asset.fields.file['de-DE'].url))
(static) processForLocale(locale, options) → {Promise.<Asset>} #
Triggers asset processing after an upload, for the file uploaded to a specific locale.
Parameters:
Name | Type | Description |
---|---|---|
locale |
string | Locale which processing should be triggered for |
options |
object | Additional options for processing |
Throws:
-
If the asset takes too long to process. If this happens, retrieve the asset again, and if the url property is available, then processing has succeeded. If not, your file might be damaged.
- Type
- AssetProcessingTimeout
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
Properties:
Name | Type | Description |
---|---|---|
options.processingCheckWait |
number | Time in milliseconds to wait before checking again if the asset has been processed (default: 500ms) |
options.processingCheckRetries |
number | Maximum amount of times to check if the asset has been processed (default: 5) |
- Source:
Example
asset.processForLocale('en-US')
.then(asset => console.log(asset.fields.file['en-US'].url))
(static) publish() → {Promise.<Asset>} #
Publishes the object
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
- Source:
Example
asset.publish()
.then(asset => console.log(asset.sys.publishedVersion))
(static) unarchive() → {Promise.<Asset>} #
Unarchives the object
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
- Source:
Example
asset.unarchive()
.then(asset => console.log(asset.sys))
(static) unpublish() → {Promise.<Asset>} #
Unpublishes the object
Returns:
Object returned from the server with updated metadata.
- Type:
- Promise.<Asset>
- Source:
Example
asset.unpublish()
.then(asset => console.log(asset.sys))
(static) update() → {Promise.<Asset>} #
Sends an update to the server with any changes made to the object's properties
Returns:
Object returned from the server with updated changes.
- Type:
- Promise.<Asset>
- Source:
Example
contentType.fields.name['en-US'] = 'Blog Post'
asset.update()
.then(asset => console.log(asset.fields.name['en-US']))