Files
The Files action evaluates its options using file generators, temporarily storing the resulting files and making them available via a randomized Mechanic URL.
This action is most useful in concert with mechanic/actions/perform, by which a task may take the resulting file URLs and pass them on to another service. Used by itself, this action can also be useful for quickly testing file generators.
Options
This action accepts a JSON object, whose keys are filenames and whose values are file generators. In this way, many files may be defined and generated by a single Files action.
Result
In Mechanic, actions are performed after their originating task run concludes. Actions are not performed inline during the task's Liquid rendering.
To inspect and respond to the results of an HTTP action, add a task subscription to mechanic/actions/perform, allowing the action to re-invoke the task with the action result data.
Learn more: Responding to action results
A Files action returns an object having the same keys (i.e. filenames) as its input. Each value is an object, having the following properties:
File property
Description
expires_at
An ISO8601 timestamp, specifying when the file will expire
mime_type
The MIME type of the generated file
name
The filename, as given in the original action options
size
The size of the generated file, in bytes
url
The URL at which this file will be available, until it expires
Example
This task generates a variety of files. It then re-invokes itself (via mechanic/actions/perform), sending an email containing links to each of the generated files.
Last updated