Attachments
How files work in Stubber: what a file object is, where a stub's files are kept, and how to attach files with tasks, form fields and notifications.
File objects
Uploaded files are stored on Stubber's file server. Your process never holds a file's content, only a small file object that points to it:
Some file objects have extra keys, such as f_id on files uploaded through a form. You can ignore them.
A file object is plain JSON, so you can pass it between tasks, notifications and stubs without copying the file. See Files And File Handling for how Stubber stores files.
Where a stub's files are kept
stub.attachments
Every stub has an attachments array holding a file object for each file attached to it. The Files tab on a stub shows this array.
stubpost.attachments
Each stubpost also has an attachments array, but it only holds the files attached during that action.
Substituting files
Use substitution wherever a file object or list of file objects is expected:
~~stub.attachments- every file on the stub~~stub.attachments[0]- the first file object on the stub~~stub.attachments[0].fileuuid- the UUID of the first file~~stubpost.attachments- the files attached in the current action
Attaching files with tasks
upload_file
Use upload_file when the file is not on Stubber yet.
attach_file
Use attach_file when the file is already on Stubber, for example a file made by an earlier task. Pass a fileuuid or a full file object.
To copy every file from one stub to another, use "files": "~~stub.attachments".
Some tasks attach the files they create automatically, such as Generate PDF and Extract Zip File. Check each task's documentation.
Attaching files with a file field
Add a file field to an action form to let users upload files when they run the action:
When the action is submitted:
- The uploaded files are attached to the stub, so they appear in
stub.attachmentsand on the Files tab. - The field's value is saved as an array of file objects under the field's name, in both
stubpost.dataandstub.data.
For the field above, the stubpost contains:
The value is an array, so use an index to get a single file:
~~stubpost.data.supporting_documents- every file uploaded in this field~~stubpost.data.supporting_documents[0]- the first file object~~stubpost.data.supporting_documents[0].fileuuid- the UUID of the first file
In later actions, read the files from stub.data.supporting_documents instead.
stub.attachments holds every file on the stub. A field's value only holds the files uploaded in that field, so use it when you need a specific document, like "the ID document the customer uploaded".
Sending files in notifications
Notifications accept file objects or file UUIDs, just like tasks: