Automantic compress files after upload
Project description
Django Compress Storage
=======================
[![Build Status](https://travis-ci.org/valdergallo/django-compress-storage.png?branch=master)](https://travis-ci.org/valdergallo/django-compress-storage)
[![Latest Version](http://img.shields.io/pypi/v/django-compress-storage.svg)](https://pypi.python.org/pypi/django-compress-storage)
[![BSD License](http://img.shields.io/badge/license-BSD-yellow.svg)](http://opensource.org/licenses/BSD-3-Clause)
Custom Field for Django that auto compact file uploaded
Features
--------
- Compress FileUpload storage file with Zip
- Delete old file that was compressed on zip
- Support for South Migrations
- Support Django 1.2+
- Celery 2.8+ support - async compress file with Celery
- Windows Support
- Linux support
- OSx support
- Support for Python3
- Support for Python2.6+
Motivation
----------
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
------------------------------
```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
INSTALLED_APPS = (
...
...
'compress_storage',
)
```
Usage
-----
```python
# example model.py
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):
return self.name
```
Shell
-----
```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/test.zip>
```
Using with Celery
-----------------
By default compress_field use Celery if Celery are installed on Site Packages.
You just need create one post_save on your model to start compress. If you wanna
auto compress after save.
```python
# listeners.py file
from django.db.models.signals import post_save
def auto_compress_file_on_post_save(sender, instance, **kargs):
instace.upload_file.compress()
post_save.connect(auto_compress_file_on_post_save, sender=MyContent)
```
Developer
---------
```bash
# download code
git clone https://github.com/valdergallo/django-compress-storage
# install developer packages
setup.py develop
# test project
setup.py test
#clean extra content
setup.py clean
```
=======================
[![Build Status](https://travis-ci.org/valdergallo/django-compress-storage.png?branch=master)](https://travis-ci.org/valdergallo/django-compress-storage)
[![Latest Version](http://img.shields.io/pypi/v/django-compress-storage.svg)](https://pypi.python.org/pypi/django-compress-storage)
[![BSD License](http://img.shields.io/badge/license-BSD-yellow.svg)](http://opensource.org/licenses/BSD-3-Clause)
Custom Field for Django that auto compact file uploaded
Features
--------
- Compress FileUpload storage file with Zip
- Delete old file that was compressed on zip
- Support for South Migrations
- Support Django 1.2+
- Celery 2.8+ support - async compress file with Celery
- Windows Support
- Linux support
- OSx support
- Support for Python3
- Support for Python2.6+
Motivation
----------
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
------------------------------
```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
INSTALLED_APPS = (
...
...
'compress_storage',
)
```
Usage
-----
```python
# example model.py
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):
return self.name
```
Shell
-----
```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/test.zip>
```
Using with Celery
-----------------
By default compress_field use Celery if Celery are installed on Site Packages.
You just need create one post_save on your model to start compress. If you wanna
auto compress after save.
```python
# listeners.py file
from django.db.models.signals import post_save
def auto_compress_file_on_post_save(sender, instance, **kargs):
instace.upload_file.compress()
post_save.connect(auto_compress_file_on_post_save, sender=MyContent)
```
Developer
---------
```bash
# download code
git clone https://github.com/valdergallo/django-compress-storage
# install developer packages
setup.py develop
# test project
setup.py test
#clean extra content
setup.py clean
```
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
Close
Hashes for django-compress-storage-0.7.9.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b531b263fb56baeb41c8586541b539ace5c19a5ca92ac4bd2f65f14c94b7ea |
|
MD5 | c3779ec57990a4ab93ce4e07c512f04f |
|
BLAKE2b-256 | 8d7cfd69264bec98012b1798c3527bed93946d061355203429f475bc3a4df995 |