Tasks
Attach file
Attaches a file to the stub. The file has to be uploaded to Stubber using a file field or other means before it can be attached.
You can also upload a file from a custom URL to Stubber using the upload_file
task.
Basic usage
Parameters
required string
fileuuid The uuid of the file to be attached to the stub. This parameter is not required if the files
parameter is set.
string
filename Sets the filename of the attached file.
string
contentType Sets the mime type of the attached file.
required string
files The list of files to be attached to the stub. Each item in the list accepts a fileuuid
, filename
, and contentType
parameter. This parameter is not required if the fileuuid
parameter is set.
Result
Properties
string
fileuuid The uuid of the attached file.
Examples
Attach pdf
Attaches a pdf to a stub.
Attach pdf using a file details object
Attaches a pdf to a stub using the file object that was return by a previous task.
The fileuuid
, filename
and contentType
should either be removed of left as empty strings.
The files parameter is an array of objects, also allowing the attaching of multiple files.
In this example, the file object is (substituted)[https://docs.stubber.com/docs/concepts/substitution#value-replacement-substitution] from the payload of the provider_create_pdf_quote
task that runs just before this attach_file task. The entire object is returned in the substitution process.
Consider Stubpost tasks Data
Attach multiple files
The following example attaches a pdf and an image to a stub. The files
parameter is an array of objects, allowing the attaching of multiple files. ~~stub.attachments
could also be used as value replacement variable substitution to attach multiple files from the current stub to another stub.
Using value replacement variable substitution to attach multiple files from the current stub to another stub. ~~stub.attachments
refers to an array of file objects that were attached to the current stub.
Consider Stubpost tasks Data