本文介绍了是否可以使用django_compressor / S3 / gzip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何使用django_compressor将gzip文件发送到Amazon S3?How is it possible to use django_compressor to send gziped files to Amazon S3?我尝试过几种方式但没有起作用。这是我最后一次的settings.py配置:I tried in several ways but it didn't work. Here is my last settings.py configuration:COMPRESS_ENABLED = TrueCOMPRESS_OFFLINE = TrueCOMPRESS_ROOT = STATIC_ROOTCOMPRESS_URL = "http://xxx.cloudfront.net/"STATIC_URL = COMPRESS_URLCOMPRESS_OUTPUT_DIR = 'CACHE'#COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage'COMPRESS_STORAGE = 'core.storage.CachedS3BotoStorage'STATICFILES_STORAGE = 'compressor.storage.GzipCompressorFileStorage'COMPRESS_YUI_BINARY = 'java -jar contrib/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar'COMPRESS_YUI_JS_ARGUMENTS = ''COMPRESS_CSS_FILTERS = ['compressor.filters.yui.YUICSSFilter']COMPRESS_JS_FILTERS = ['compressor.filters.yui.YUIJSFilter']COMPRESS_CSS_HASHING_METHOD = 'hash'和我的 storage.pyfrom django.core.files.storage import get_storage_classfrom storages.backends.s3boto import S3BotoStorageclass CachedS3BotoStorage(S3BotoStorage): """ S3 storage backend that saves the files locally, too. """ def __init__(self, *args, **kwargs): super(CachedS3BotoStorage, self).__init__(*args, **kwargs) self.local_storage = get_storage_class( "compressor.storage.CompressorFileStorage")() def save(self, name, content): name = super(CachedS3BotoStorage, self).save(name, content) self.local_storage._save(name, content) return name推荐答案 django-storages S3存储后端支持gzip 。添加到settings.py:django-storages S3 storage backend supports gzip. Add to settings.py:AWS_IS_GZIPPED = True 这篇关于是否可以使用django_compressor / S3 / gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-22 08:33