Working with Attachments

How files are stored

When an attachment is uploaded to a form, it is uploaded to a filestore and a reference to that file is stored in the attachment field. When returned via the API as part of the values from the submission, it looks something like this:

     "Attachments": [
      "contentType": "image/png",
      "link": "/space-slug/submissions/8f0feb79-fd56-11e8-aca1-852d4a633f0e/files/Attachments/0/image.png",
      "name": "image.png",
      "size": 12426

How to access files

The data stored in the submission contains the content type, the name of the file, and a link to the file in filehub. However, this link is not the ideal link for most use in downloading. There is a specific API endpoint for downloading attachments from a submission:


You need the submission id, the field name, the file name, and the file index. In the example above, the file index is 0. This endpoint will give you a link that is valid for downloading the file for 5 seconds.

This time of expiring link is what is used when the user clicks on an attachment in the UI and in, for example, the clone attachment handler when the attachment is retrieved to copy.

How not to use attachments

Because files are always referenced with these temporary/expiring URLs, they are never cached by the clients. This means CE submissions are not good places to store images that are to be used in the theme or in any other way repeatedly loaded by the user's browser.