Understanding Stored Files

Anne Ramey

How files are stored

When your users attach a file into an attachment field, it is not stored in the Cassandra database with the rest of their submission. It is, instead, stored in whatever filehub structure (Local, S3, Azure, Sharepoint, etc) you have set up and connected to that Space. 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 filestore files & why

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.