Sam*_*amy 5 django amazon-s3 amazon-ec2 django-storage
我已经谷歌搜索了两天,但没有一个答案可以解决这个问题。
设置
AWS_S3_ACCESS_KEY_ID = 'xxxxxxx'
AWS_S3_SECRET_ACCESS_KEY = 'xxxxxxxxx'
AWS_STORAGE_BUCKET_NAME = 'my-bucket.mycompany.com'
COMPRESS_URL = 'http://{}.s3.amazon.com/'.format(AWS_STORAGE_BUCKET_NAME)
STATIC_URL = COMPRESS_URL
AWS_S3_FILE_OVERWRITE = True
AWS_S3_SECURE_URLS = True
AWS_QUERYSTRING_AUTH = False
AWS_S3_CUSTOM_DOMAIN = '{}.s3-external-3.amazonaws.com'.format(AWS_STORAGE_BUCKET_NAME)
Run Code Online (Sandbox Code Playgroud)
谷歌搜索
服务器上的日期/时间不正确 :这是一个 EC-2 实例,但即使我安装了yum install ntp ntpdate ntp-doc-- 运气不好
AWS_QUERY_STRING_AUTH:多个在线来源表示要这样做,但没有解决我的问题
AWS_S3_CUSTOM_DOMAIN这里也不走运
本实验
# ON THE EC2 BOX
./manage.py shell
from boto.s3.connection import S3Connection
from django.conf import settings
conn = S3Connection(settings.AWS_S3_ACCESS_KEY_ID, settings.AWS_S3_SECRET_ACCESS_KEY)
b = conn.get_bucket('my-bucket.mycompany.com')
key = b.get_key('500.html')
print key.get_contents_as_string() # WORKS FINE
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时./manage.py compress我得到
CommandError: An error occured during renderinghome_4770.html:
'https://mybucket.mycompany.com.s3-external-3.amazonaws.com/css/smoothness/jquery-ui-1.10.1.custom.css'
isn't accessible via COMPRESS_URL ('http://mybucket.mycompany.com.s3.amazon.com/') and can't be compressed
Run Code Online (Sandbox Code Playgroud)
在您询问之前,是的,该文件在该存储桶上可用。我还尝试了传统的 django-storages 离线压缩方式,使用<project-root>/staticas ,然后上传AND :STATIC_ROOT的内容,即生成的 css/js 和文件到存储桶,但在浏览器中,我仍然获取css/js 文件./manage.py collectstatic./manage.py compressmanifest_1.json403 Forbidden
对可能发生的事情有什么想法吗?
您是否在您的存储桶上设置了 CORS 策略?您可能还需要添加权限以允许“Everyone”“列出”存储桶中的对象(尽管首先尝试 CORS 策略)
编辑:以下是文档:http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html
| 归档时间: |
|
| 查看次数: |
2840 次 |
| 最近记录: |