Guides
Attachments
Understanding file UUIDS and using them in attachments.
In order to attach files to any sort of notification, you need to understand the JSON data structure of files uploaded to a stub and then how this is used in the notification to attach a file.
The notification library has examples of how to reference an uploaded file's data, eg. its UUID.
The Files UUID
The file's UUID is its unique identifier in Stubber's file server.
This can be found in different places:
File Section
Navigate to the Files section in a stub and locate the file you would like to attach.
Right Click on the little download icon and click Copy Link Address
Paste the url into a text editor of your choice.
The File's unique UUID is the text that appears after the last /
Stub Data
- Open up the Data section on the stub.
- Find the file field name the file was upload to.
- Click on the
+
to the left of the field name - Click on the
+
to the left of the first array element - The UUID in the value of
fileuuid
as below.
Uploaded File JSON Structure
In the screenshot above, you will notice the uploaded file's data in the stub has a specific structure.
Lets take a look at this structure a little closer:
The field name this file was uploaded into is files
. As you can see, files
is an array of objects. Each file that was uploaded into the field is an object in the array.
The file's UUID is stored inside each object.
Referring to the File
When referring to the file, some notifications require just the UUID and others use the entire file's object. In most cases, both formats are supported.
Using only File UUID
You would refer to the file's UUID as : ~~stub.data.files[0].fileuuid
This provides only the UUID.
Using the File's object
You would refer to the file's object as : ~~stub.data.files[0]
This will preserve the entire file's JSON structure with all its key : value pairs.
Using in Notifications
Please see this topic for sending an attachment via email. Attaching files to Email
Please see this topic for sending an attachment via WhatsApp. Send a file via Whatsapp