File generators
Last updated
Was this helpful?
Last updated
Was this helpful?
File generators are invoked by to create new files, using options provided by the action, and handing the resulting file back to the action for further use. In this way, can make choices about what files to generate, and what to do with the results.
File generator
Purpose
Decodes base64-encoded content, returning a file containing the results
Renders HTML using a full Webkit browser, returning a PDF file of the results
Allows defining file contents using a plain string, instead of a file generator object
Downloads and returns a file
Accepts its own set of file generators, returning a ZIP archive of the results
Generated files may each be a maximum of 20MB.
File generator objects, like , are plain JSON objects each having a single key, and a single value. The object key specifies which file generator is to be invoked; the object value contains the options used for that generator.
In practice, file generator objects are given as values in a larger JSON object, in which filenames are mapped to file generators.
These are the Mechanic actions that support file generators.
Action
Usage
Uses file generators to prepare email attachments
Uses file generators to prepare temporary URLs, from which the generated files can be downloaded
Uses file generators to prepare FTP uploads
Adds generated files to a multipart/form-data HTTP request
The file generator is invoked implicitly by supplying a string, instead of supplying the usual file generator object.
In the following example, a action is defined, mapping filenames ("invoice.pdf"
, "external.jpg"
, and plain.txt
) to file generators (a PDF generator, a URL generator, and â implicitly â a plaintext generator). Note how the file generator invocation varies, based on the specific file generator in play.