Project Description

A Django module which extends pyfilesystem2 with several methods tomake it convenient for web use. Specifically, it extends pyfilesystem2with two methods:

fs.get_url(filename, timeout=0)

This will return a externally-usable URL to the resource. Iftimeout>0, the URL may stop working after that period (inseconds). Details are implementation-dependent. On Amazon S3, this isa secure URL, which is only available for that period. For a staticfilesystem, the URLs are unsecure and permanent.

fs.expire(filename, seconds, days, expires=True)

This allows us to create temporary objects. Our use-case was that wewanted to generate visualizations to users which were .png images. Thelifetime of those images was a single web request, so we set them toexpire after a few minutes. Another use case was memoization.

Note that expired files are not automatically removed. To remove them,call `expire_objects()`. In our system, we had a cron job dothis for a while. Celery, manual removals, etc. are all options.

To configure a django-pyfs to use static files, set a parameter inDjango settings: