Skip to content

HOWTO Store files in S3

Justin Forest edited this page May 14, 2024 · 7 revisions

Tree photos take a lot of space. A single photo can take around 4-5 Mb. A site with many trees can require a lot of disk space, which might not be available or might not be cheap at the hosting server. It is more convenient to use an S3 compatible file storage.

When an S3 compatible storage is used, the workflow is the following. When a file is uploaded, it is saved in the local file storage, then later uploaded to the S3 storage, and deleted from the local storage on success. When a file is requested, it is first looked for in the local storage, if not found -- in the S3 storage, otherwise a 404 error is returned. Files are always accessed via the API, so the S3 storage lets you save disk space, not data transfer; you need to use a CDN to minimize data transfer for your app server.

To enable the S3 file storage, the following environment variables need to be defined:

AWS_ACCESS_KEY_ID=secret
AWS_SECRET_ACCESS_KEY=secret
Clone this wiki locally