Skip to main content

A quick, rough around the edges Django application to remember and remove temporary files.

Project description

django-cleanup-later

A quick, rough around the edges Django application to remember and remove temporary files.

The purpose of this application is to allow the user to create a temporary file (e.g. for the purpose of streaming or to allow a time limited availability) and automatically remove it after a given period of time.

At present this can be done automatically using the provided middleware, manually by running the cleanup_later management command, or by calling the CleanupFile.cleanup() function directly.

It's been developed and tested on Python 3.7 and Django 2.2 .. your mileage may vary with other configurations.

Installation

Install via pip or download the repository:

pip install django-cleanup-later

Add the app to your INSTALLED_APPS setting:

INSTALLED_APPS = [
        ...
        'cleanup_later',
    ]

Make sure to migrate:

manage.py migrate

And optionally add the middleware if you want files to be removed automatically without the need for a cron or background process:

MIDDLEWARE = [
    ...
    'cleanup_later.middleware.CleanupMiddleware',
]

Note that using the middleware probably isn't the most efficient approach. If your project is using a cron or celery for background processing, it's more efficient to run the cleanup from there.

Usage

To use the app, simply register the filename you would like to later cleanup like so:

from cleanup_later.models import CleanupFile

CleanupFile.register('file_to_delete.txt')

By default, files will be deleted after 10 minutes, but you can override this by specifying a validity parameter as a timedelta .. e.g.

CleanupFile.register('file_to_delete.txt', timedelta(minutes=30))

Simples!

Contributing

Pull requests are welcome if you find this library useful.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-cleanup-later-0.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file django-cleanup-later-0.1.tar.gz.

File metadata

  • Download URL: django-cleanup-later-0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.19.5 CPython/3.6.7

File hashes

Hashes for django-cleanup-later-0.1.tar.gz
Algorithm Hash digest
SHA256 91fc4ce9ca193d31ff4e47f0558331bdf7e0de3b3fe80ee98f06d6b2a886380e
MD5 9d5e216cdb392045ca0738fa62920a58
BLAKE2b-256 965279f706736d548416531a1e98ecdfdc310979a1f0eb33f08631c05b22bbbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page