如何使用django_compressor將gziped文件發送到Amazon S3?是否可以使用django_compressor/S3/gzip?
我嘗試了幾種方法,但它沒有奏效。這是我最後的settings.py配置:
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_URL = "http://xxx.cloudfront.net/"
STATIC_URL = COMPRESS_URL
COMPRESS_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.py
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
class 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_compressor的GitHub:https://github.com/jezdez/django_compressor/issues/368 – kevinharvey 2013-03-05 15:42:10
祝你好運@kcharvey!我期待着下一個版本:-D – Thomas 2013-03-06 04:01:28
任何人排序?我試圖讓這個工作。 – Murph 2013-05-22 22:10:16