Working with Files and Media
Application vs. Journey Assets
Airkit handles files and media in two ways on that is part of the application and shared across all users and the other is stored within a particular user's journey.
App Assets
App Assets are files & media that are included in the application itself and can be referenced through the Studio when designing an experience. Examples Include:
- Images in a web experience (PNG, JPG, etc.)
- Documents to download (PDFs, ZIP etc.)
- Or other media such as videos (MP4)
These assets need to be included in your Media Library and are made available through special URLs that resolve securely to a user through your custom domain and quickly as through the Airkit CDN.
Journey Assets
Journey Assets are files that are associated with a specific user's journey within Airkit and can be stored within variables and used within data operations. Some common examples include:
- Photos captured from a customers mobile device
- Files uploaded from a customer
- Customer signatures (PNG)
- Generated PDF files (Form fills, merged PDFs or custom generated)
Because Journey Assets are stored in variables the scope of how long they are available is determined by whether the Journey is active or expired, please see Journey State for more information.
Working with Assets in Variables
The Asset data type of a variable allows you to work with files and media within a journey using Airscript and within Data Flows.
Real-World Use Cases
Some examples of when you might use a variable with the Asset data type to receive or handle a file
- The Media Upload web control to receive photos from a mobile device's camera or photo library
- The Media Upload web control to receive files from a mobile device or desktop
- The Signature Pad web control to capture a users hand-written e-signature
- Creating a new PDF from an HTML template with user specific values using the HTML to PDF Data Operation
- Filling the fields of a form-fillable PDF template with user specific values using The Fill PDF Form Data Operation
- Merging the pages of multiple PDFs together using The Merge PDF Data Operation
- Generating a flat file from journey or batch data using The Create File Data Operation
- Combining and compressing multiple files together with The ZIP File Data Operation
- Sending files as attachments on emails with The Send Email Data Operation
- Sending files securely with The SFTP Data Operation
- Looking up file meta information with The Fetch Asset Details Data Operation
- Deleting one or more Assets with The Delete Assets Data Operation
- Getting a temporary download URL to share with a user with The Fetch Asset Details Data Operation
Embedding Assets within Your Application
Using Media Library you can upload assets to be included and referenced in your application
Once a file has been uploaded into your Media Library you now have an Asset URI to use to reference the file while building your app.
Inserting Images using the Image Web Control
Why Does Airkit Use Special URLs for Assets?
You may notice that the way Airkit refers to files is not a typical URL and isn't able to be retrieved outside of the Airkit platform. There are two primary reasons for using a specific URI
- Security - these Asset URIs can only be accessed in the context of an Airkit operation such as within a journey of a user and are dynamically exchanged for temporary URL
- Version Control - we want to make sure that files are tracked across versions of applications easily and caching issues do not arise
What are the components of an Asset URI?
asset://[Access Scope]:[Organization UUID]/[Application UUID]:[File UUID]:[Version Number]
- Access Scope: Global or user specific
- Organization UUID: Your Organizations ID
- Application UUID: The specific branch of the application that is serving the asset. This is used for version control so that asset links will still function for journeys that started on an older branch of your application
- File UUID: Uniquely represents the file within your application's Media Library
- Version Number: An auto-incrementing version number of an asset
Working with Assets in Data Operations
A quick walk through of some Data Operations that work with Assets
There are quite a few Data Operation that either produce files or consume files to perform their actions and all of these functions leverage the Asset variable type to provide or pass around references to the underlying files. For example:
Operations that Create or Consume Files
- Create File produces any file type and inserts content such as TXT, JSON, XML, CSV, TSV
- Fill PDF Form takes a blank PDF template and merges values into form field to produce a filled PDF
- HTML to PDF creates a custom PDF using HTML for layout, styling and allowing full control over data and dynamic content including inserting images, CSS, footers/headers, page breaks and more
- Merge PDF provides an operation to combine the pages of multiple PDF files into one PDF
- Create ZIP File provides an operation to combine and compress multiple files into a single ZIP file
Operations that Transmit Files Externally
- Send Email allows to attach one or more files to an outbound email originated from Airkit
- SFTP allows sending a file securely over FTP to remote server
Operations that Support Asset Operations
- Fetch Asset Details given an Asset URI looks up file details such as (name, type, size) and provides a temporary URL to download the underlying file
- Delete Assets removes the underlying file(s) from the server for an asset
Updated almost 3 years ago