Skip to main content

www.tmkn.org

← Blog

wagtail-storages

Recently I have been busy working on wagtail-storages. It is a Wagtail plugin. It makes it easy to have private files in Wagtail that are served directly with S3.

When would you need it?

  • A single Wagtail website that has both public and private collections of documents.
  • Documents are stored on S3 and perhaps served from behind a CDN.
  • You don’t want to be proxying all files through a Python view. E.g. your hosting platform times out or you serve big files and it blocks your Python server.

What is wagtail-storages?

wagtail-storages is a collection of signal handlers that do the following:

  • On document or its privacy control change, update object ACLs on S3, i.e. if it has restrictions set object ACL to private and if it does not, set ACL to public-read.
  • Purge the document from front-end cache on changes. There is an option to specify an extra front-end cache invalidator configuration besides the one used for purging pages. This feature uses the already excellent Wagtail’s built-in module so it was a simple job.
  • When document is served, the document view takes a decision to either redirect user to the CDN or create a one-off signed URL for private documents.

The project can be found on GitHub and PyPi.

← Blog