使用Django和s3boto,一些管理图像(icon_clock.gif&安培; icon_calendar.gif)不显示 [英] Using Django and s3boto, some admin images (icon_clock.gif & icon_calendar.gif) don't display
问题描述
所有文件,包括那些没有正确显示,是present在我的水桶亚马逊。不显示我发现只有两个图像icon_clock.gif和icon_calendar.gif。其他一切工作正常。
当我检查破碎的形象的链接位置,我得到这样的:
https://my_bucket_name.s3.amazonaws.com/admin?Signature=MY_SIGNATURE&AWSAccessKeyId=MY_KEYimg/icon_clock.gif
正如你所看到的,查询参数没有被添加到结束,而是要链接的中间。
下面是相关设置:
导入os.path中
ROOT_DIR = os.path.abspath则(os.path.join(os.path.dirname(__ FILE__),'..'))
PROJECT_NAME = os.path.basename(ROOT_DIR)
高清绝对路径(*参数):
返回os.path.join(ROOT_DIR,*参数)
STATIC_ROOT =绝对路径(静态)
AWS_ACCESS_KEY_ID ='MY_KEY
AWS_SECRET_ACCESS_KEY ='MY_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME ='my_bucket_name
STATICFILES_STORAGE ='storages.backends.s3boto.S3BotoStorage
S3_URL =HTTP://%s.s3.amazonaws.com/'%AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
这似乎是固定的Django的储量目前的开发版本。请参阅<一href="http://$c$c.larlet.fr/django-storages/issue/121/s3boto-admin-$p$pfix-issue-with-django-14">issue 121 了解更多信息。
快速解决方法步骤:
- 替换
Django的货仓
在requirements.txt与-e hg+https://bitbucket.org/david/django-storages@e27c8b61ab57e5afaf21cccfee005c980d89480f#egg=django_storages-dev$c$c>
- 在您的设置,添加
AWS_QUERYSTRING_AUTH =假
。此设置的结果是AWS身份验证的东西是不包含在每个URL。难道这只是如果你的S3存储桶中的所有文件都是公开的。
All files, including those not displaying correctly, are present in my bucket at amazon. The only two images I've found that don't display are icon_clock.gif and icon_calendar.gif. Everything else works properly.
When I examine the link location of the broken images, I get this:
https://my_bucket_name.s3.amazonaws.com/admin?Signature=MY_SIGNATURE&AWSAccessKeyId=MY_KEYimg/icon_clock.gif
As you can see, the query parameters aren't being added to the end but instead to the middle of the link.
Here are the relevant settings:
import os.path
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
PROJECT_NAME = os.path.basename(ROOT_DIR)
def ABS_PATH(*args):
return os.path.join(ROOT_DIR, *args)
STATIC_ROOT = ABS_PATH('static')
AWS_ACCESS_KEY_ID = 'MY_KEY'
AWS_SECRET_ACCESS_KEY = 'MY_SECRET_ACCESS_KEY'
AWS_STORAGE_BUCKET_NAME = 'my_bucket_name'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
This seems to be fixed in the current development version of django-storages. See issue 121 for more information.
Quick workaround steps:
- Replace
django-storages
in your requirements.txt with-e hg+https://bitbucket.org/david/django-storages@e27c8b61ab57e5afaf21cccfee005c980d89480f#egg=django_storages-dev
- In your settings, add
AWS_QUERYSTRING_AUTH = False
. The result of this setting is that the AWS auth stuff is not included in every URL. Do this only if all files in your S3 bucket are public.
这篇关于使用Django和s3boto,一些管理图像(icon_clock.gif&安培; icon_calendar.gif)不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!