An Asset represents a file within an Airkit Application and contains the information necessary to access that file. This means that there are certain properties an Asset is required to have (which includes properties such as the assetKey and id).
In addition to the required properties, an Asset can also include other properties that describe information such as the file type, size, and state of the Asset. These are not required in order to classify a Data Type as an "Asset", but they are required to classify a Data Type as a "Detailed Asset".
Structure
A Detailed Asset is a subcategory of Asset that contains the following properties in addition to the properties contained by all Assets:
displayName (string
) - the filename of the Asset like "textfile.txt" or "myimage.jpg".
description (string
) - currently an unused property; will be NULL.
size (number
) - the size of the Asset in bytes. The maximum limit is 10 megabytes.
expiration (number
) - refers the to the number of milliseconds that the Asset still has before expiration. This value is updated each time the download link is fetched. Private Assets expire after a maximum of seven days. Global Assets do not expire; expiration
values associated Global Assets are not valid.
scope (string
) - refers to the scope of the Asset. Can have a value of APP, in which case it is tied to the application and be accessed by any instance, or SESSION which means that Asset is tied to the user session. If an Asset contains personal info, it is probably best to ensure the scope is SESSION and if the Asset should be accessible to anyone through Media Library, it should be set to APP.
region (string
) - specifies where the Asset should be available for public CDNs. This is only relevant to Public assets.
createdTime (string
) - Timestamp indicating when the Asset was created.
modifiedTime (string
) - Timestamp of the last modification of the Asset.
deletedTime (string
) - If the Asset has been deleted, this is the is the timestamp of the deletion time. NULL otherwise.
validationErrors (string
) - this message is text generated by Airkit to display errors with creation of Assets, for various reasons like size issues, viruses, and invalid kinds. NULL if no errors.
extraInfo (any
) - used by some integrations to store information about the creation of an Asset. You can write to it to store extra information on your Asset. NULL otherwise.
downloadUrl (string
) - a URL for downloading this Asset.
thumbnailUrl (string
) - the URL for an Asset's thumbnail if it has one. NULL otherwise.
state (string
) - to the state of the Data. Available options are "DRAFT", "PENDING", or "ACTIVE".
- "DRAFT" means the Asset has been declared but hasn't been fully received yet.
- "PENDING" is the state after the Asset has been fully received, but the server side processing is not yet finished.
- "ACTIVE" is a fully queryable Asset.
type (string
) - refers the MIME type of the Asset. It can be text, image, or any other valid type. Here is a table of supported data types:
Mime Type | Type of Data |
---|---|
image/jpeg | Jpeg Image |
image/png | PNG Image |
application/pdf | |
image/svg+xml | An SVG XML file |
image/gif | GIF image |
audio/mpeg | MPEG Audio data |
audio/mp3 | An MP3 file |
audio/wav | WAV audio file |
video/mp4 | MP4 Video file |
text/html | HTML file |
application/zip | Compressed Zip file |
application/pgp-encrypted | First part of PGP encrypted data, body |
application/vnd.ms-excel | Microsoft Excel file |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | Microsoft Excel (OpenXML) |
font/otf | OpenType font |
font/ttf | TrueType Font |
font/woff | Web Open Font Format (WOFF) |
font/woff2 | Web Open Font Format (WOFF) |
Examples
A Detailed Asset is returned by the Fetch Asset Details Data Operation. The File Upload Control also interprets files uploaded by users as Detailed Assets, which is accessible within the Control as event.value.asset
.
Detailed Assets are useful when you need to access specific and detailed information pertaining to an Asset, such as its file type, size, or state. Additionally, there are some Airscript Functions, such as ASSET_TYPE and ASSET_STATE, that require input in the form of a Detailed Asset.
For the sake of example, assume all of the following Airscript expressions have access to the following Detailed Asset, example_detailed_asset
:
example_detailed_asset = {
"id": "ead7b376-6560-415a-917a-0fb1cc58f3eb",
"assetKey": "d527500a-502d-463b-8fe0-eddf7397fbe2",
"organizationId": "8e52c37f-4071-4dbb-8a98-d9096d9b69d2",
"displayName": "placekitten.jpeg",
"description": null,
"type": "image/jpeg",
"size": 6483,
"version": 0,
"expiration": 600000,
"visibility": "GLOBAL",
"state": "ACTIVE",
"scope": "APP",
"region": "us-west-2",
"createdTime": "2022-05-02T17:31:27.517Z",
"modifiedTime": "2022-05-02T17:31:29.187Z",
"deletedTime": null,
"validationErrors": null,
"extraInfo": null,
"downloadUrl": "https://us.api.prod.airkit.com/internal/assets/8e52c37f-4071-4dbb-8a98-d9096d9b69d2/d527500a-502d-463b-8fe0-eddf7397fbe2/ead7b376-6560-415a-917a-0fb1cc58f3eb/0",
"thumbnailUrl": "https://us.api.prod.airkit.com/internal/assets/8e52c37f-4071-4dbb-8a98-d9096d9b69d2/d527500a-502d-463b-8fe0-eddf7397fbe2/ead7b376-6560-415a-917a-0fb1cc58f3eb/0_t",
"storageClass": "v1",
"hash": "7R9Xl32QisD+9kMlW5nde0ESFiSdO1LCgGwaqL4aXuo=",
"hashType": "SHA256"
}
The function ASSET_SIZE takes a Detailed Asset as input and returns the Detail Asset's size in bytes. In the following example, ASSET_SIZE returns the size of example_detailed_asset
:
ASSET_SIZE(example_detailed_asset) -> 6483
The size of a Detailed Asset can also be referenced with dot notation, such as in the following example. Note that this returns the same value as the example above:
example_detailed_asset.size -> 6483
When Assets are collected from users as part of an application flow, it is often useful to display either the thumbnail or the full image of the uploaded Asset shortly after. This can be done by using referencing the thumbnailUrl or downloadUrl property in the Image URL property of an Image Web Control. Accessing the thumbnailUrl or downloadUrl property of a particular Detailed Asset is done with dot notation.
The following example shows how the thumbnailUrl can be accessed via dot notation by referencing the thumbnailUrl
property of example_detailed_asset
:
example_detailed_asset.thumbnailUrl -> "https://us.api.prod.airkit.com/internal/assets/8e52c37f-4071-4dbb-8a98-d9096d9b69d2/d527500a-502d-463b-8fe0-eddf7397fbe2/ead7b376-6560-415a-917a-0fb1cc58f3eb/0_t"
The following example shows that the downloadUrl
can be referenced similarly:
example_detailed_asset.downloadUrl -> "https://us.api.prod.airkit.com/internal/assets/8e52c37f-4071-4dbb-8a98-d9096d9b69d2/d527500a-502d-463b-8fe0-eddf7397fbe2/ead7b376-6560-415a-917a-0fb1cc58f3eb/0"