Assets
The most common use case for an asset is to store an image or video to display in your Epicenter application's UI. An asset can contain any BLOB.
The file containing the contents of the asset is stored in AWS S3.
For data that is better suited for the JSON format, consider using a vault.
To manage assets with the JS libraries, use the Asset adapter.
Asset object
Epicenter creates and stores an Asset object containing the asset metadata, which can include the asset's address, scope, permit, and expiration time.
Automatic asset deletion
If the optional expiration time is set, the asset gets deleted at that time and becomes unavailable.
It is best practice to avoid setting an expiration time and to rely on the scope to determine the asset's lifespan. In that case, the asset is deleted when the entity defining its scope is deleted. For example, if an asset is scoped to a group, it is deleted when the group is deleted.
Address
Asset objects are associated with specific entities within an account and project. These entities are identified by the asset's address.
Creating assets
To add an asset to your Epicenter application, use one of these Asset adapter functions:
create()adds a new asset record to your project and returns an upload link, which you must use to save the asset contents to storage.store()either creates a new asset record or updates an existing one and uploads the file to storage.
Updating assets
You can update some of the asset's metadata and upload a new file to it using one of these two functions:
update()updates the metadata and returns a new upload link.store()either creates a new asset record or updates an existing one and uploads the file to storage.
Retrieving assets
You have several options for retrieving assets:
- Get the metadata for a specific asset or a list of assets within a scope.
- Get an S3 download link for the asset file.
- Call a function that redirects you to the download URL.
To retrieve asset metadata and contents, use one of the retrieval functions of the asset adapter.
Asset URL expiration
For security reasons, asset download links are valid for a limited length of time. It is best practice to request a download link for an asset just before the asset needs to be displayed in the UI, not when generating the HTML.
The download link for an existing asset is valid for one hour for audio and video content and five minutes for other content types.
Deleting assets
To delete an asset, call one of the adapter's delete functions.