上传后自动压缩文件
django-compress-storage的Python项目详细描述
Django压缩存储
=======================
构建状态最新版本bsd许可证pypi下载|
为django自定义zipfilefield,该文件自动压缩
安装
------
…代码::bash
pip安装django压缩存储
或按源代码
…代码::bash
Git克隆https://github.com/valdergalo/django-compress-storage/
python setup.py安装
功能
--
-用zip压缩文件上载存储文件
-删除压缩到zip的旧文件
-支持南迁
-支持django 1.2+
-芹菜2.5+支持-芹菜异步压缩文件
-Windows支持
-Linux支持
-OSX支持
-支持python3
-支持python2.6+
动机
----
在我的工作中,我们需要将所有上传文件保存5年。失去很多空间
在带有这些文件的服务器上,因为我创建了这个应用程序。
django设置配置
--------
…代码::python
文件压缩删除旧文件=真压缩后删除旧文件
file_compress_delete_old_file=false压缩后不删除旧文件
功能仅适用于V9.0版+
file_compress_queue='芹菜';默认情况下,queue是芹菜,但您可以使用此var on设置更改此值
已安装的应用程序=(
…
…
“压缩存储”,
)
用法
----
…代码::python
示例model.py
来自django.db导入模型
从压缩存储导入zipfilefield
MyContent类(models.model):
名称=models.charfield(最大长度=150)
创建日期=models.datetimefield(auto\u now=true)
上传文件=zipfilefield(上传到'mycontent/')
定义Unicode(自身):
返回self.name
外壳
----
…代码::python
>>>>来自example.core import mycontent
>>>m=mycontent.objects.get(id=2)
>>>m.上传文件
<;zipcompressfieldfile:mycontent/test.txt>;
>>>m.upload_file.compress()
>>>m.上传文件
<;zipcompressfieldfile:mycontent/test.zip>;
与芹菜一起使用
----
如果芹菜安装在现场包装上。你只需要创造一个
在模型上使用异步压缩后保存。
…代码::python
listeners.py文件
来自django.db.models.signals import post_save
def auto_compress_file_on_post_save(发送者,实例,**kargs):
实例.upload_file.compress()
post_save.connect(在post_save上自动压缩文件,sender=mycontent)
如果不想使用芹菜异步压缩:
…代码::python
def auto_compress_file_on_post_save(发送者,实例,**kargs):
实例.upload_file.compress(async=false)
post_save.connect(在post_save上自动压缩文件,sender=mycontent)
。
=======================
构建状态最新版本bsd许可证pypi下载|
为django自定义zipfilefield,该文件自动压缩
安装
------
…代码::bash
pip安装django压缩存储
或按源代码
…代码::bash
Git克隆https://github.com/valdergalo/django-compress-storage/
python setup.py安装
功能
--
-用zip压缩文件上载存储文件
-删除压缩到zip的旧文件
-支持南迁
-支持django 1.2+
-芹菜2.5+支持-芹菜异步压缩文件
-Windows支持
-Linux支持
-OSX支持
-支持python3
-支持python2.6+
动机
----
在我的工作中,我们需要将所有上传文件保存5年。失去很多空间
在带有这些文件的服务器上,因为我创建了这个应用程序。
django设置配置
--------
…代码::python
文件压缩删除旧文件=真压缩后删除旧文件
file_compress_delete_old_file=false压缩后不删除旧文件
功能仅适用于V9.0版+
file_compress_queue='芹菜';默认情况下,queue是芹菜,但您可以使用此var on设置更改此值
已安装的应用程序=(
…
…
“压缩存储”,
)
用法
----
…代码::python
示例model.py
来自django.db导入模型
从压缩存储导入zipfilefield
MyContent类(models.model):
名称=models.charfield(最大长度=150)
创建日期=models.datetimefield(auto\u now=true)
上传文件=zipfilefield(上传到'mycontent/')
定义Unicode(自身):
返回self.name
外壳
----
…代码::python
>>>>来自example.core import mycontent
>>>m=mycontent.objects.get(id=2)
>>>m.上传文件
<;zipcompressfieldfile:mycontent/test.txt>;
>>>m.upload_file.compress()
>>>m.上传文件
<;zipcompressfieldfile:mycontent/test.zip>;
与芹菜一起使用
----
如果芹菜安装在现场包装上。你只需要创造一个
在模型上使用异步压缩后保存。
…代码::python
listeners.py文件
来自django.db.models.signals import post_save
def auto_compress_file_on_post_save(发送者,实例,**kargs):
实例.upload_file.compress()
post_save.connect(在post_save上自动压缩文件,sender=mycontent)
如果不想使用芹菜异步压缩:
…代码::python
def auto_compress_file_on_post_save(发送者,实例,**kargs):
实例.upload_file.compress(async=false)
post_save.connect(在post_save上自动压缩文件,sender=mycontent)
。