Skip to main content

Automantic compress files after upload

Project description

Django Compress Storage

|Build Status| |Latest Version| |BSD License| |Pypi Download|

Custom ZipFileField for Django that auto compact file uploaded


.. code:: bash

pip install django-compress-storage

or by source code

.. code:: bash

git clone
python install


- Compress FileUpload storage file with Zip
- Delete old file that was compressed on zip
- Support for South Migrations
- Support Django 1.2+
- Celery 2.5+ support - async compress file with Celery
- Windows Support
- Linux support
- OSx support
- Support for Python3
- Support for Python2.6+


On my job we need save all upload files for 5 year. Losing a lot space
on server with this files, because this I created this application.

Django Settings Configurations

.. code:: python

FILE_COMPRESS_DELETE_OLD_FILE = True # to delete old files after compressed
FILE_COMPRESS_DELETE_OLD_FILE = False # to not delete old files after compressed

# Feature only for version v9.0+
FILE_COMPRESS_QUEUE = 'Celery' # by default queue is Celery, but you can change this with this var on settings



.. code:: python

# example

from django.db import models
from compress_storage import ZipFileField

class MyContent(models.Model):
name = models.CharField(max_length=150)
create_date = models.DateTimeField(auto_now=True)
upload_file = ZipFileField(upload_to='mycontent/')

def __unicode__(self):


.. code:: python

>>> from example.core import MyContent
>>> m = MyContent.objects.get(id=2)
>>> m.upload_file
<ZipCompressFieldFile: mycontent/test.txt>
>>> m.upload_file.compress()
>>> m.upload_file
<ZipCompressFieldFile: mycontent/>

Using with Celery

If Celery are installed on Site Packages. You just need create one
post\_save on your model to use async compress.

.. code:: python

# file

from django.db.models.signals import post_save

def auto_compress_file_on_post_save(sender, instance, **kargs):

post_save.connect(auto_compress_file_on_post_save, sender=MyContent)

If you don´t wanna use Celery async compress:

.. code:: python

def auto_compress_file_on_post_save(sender, instance, **kargs):

post_save.connect(auto_compress_file_on_post_save, sender=MyContent)


Project details

Download files

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

Source Distribution

django-compress-storage-0.9.1.tar.gz (4.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page