[英]Django filebrowser - resize before upload
是否可以在使用django filebrowser上传之前调整图像大小,而无需在服务器上保留原始图像大小?
Create pre_upload callback that will resize your image before saving. 创建pre_upload回调,该回调将在保存之前调整图像的大小。
from filebrowser import signals
def pre_upload_callback(sender, **kwargs):
"""
Receiver function called before an upload starts.
"""
print "Pre Upload Callback"
print "kwargs:", kwargs
# your code HERE
signals.filebrowser_pre_upload.connect(pre_upload_callback)
Filebrowser documentation on signals 关于信号的Filebrowser文档
Alternatively, if pre_upload hook doesn't work (because the file is not there yet) you can use post_upload hook, and modify the file in place. 或者,如果pre_upload钩子不起作用(因为该文件尚不存在),则可以使用post_upload钩子并在适当位置修改文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.