不一致SignatureDoesNotMatch亚马逊S3与Django的管道,s3boto和存储 [英] Inconsistent SignatureDoesNotMatch Amazon S3 with django-pipeline, s3boto and storages

查看:354
本文介绍了不一致SignatureDoesNotMatch亚马逊S3与Django的管道,s3boto和存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Django在流水线以及s3boto编译的2个文件:master.css和master.js。他们在我的水桶设置为公开。然而,当我访问他们,有时master.css供应,有时也犯错误与SignatureDoesNotMatch。在同master.js。这不会发生在Chrome。我能会丢失?

I have 2 files compiled by django-pipeline along with s3boto: master.css and master.js. They are set to "Public" in my buckets. However, when I access them, sometimes master.css is served, sometimes it errs with SignatureDoesNotMatch. The same with master.js. This doesn't happen on Chrome. What could I be missing?

修改:现在发生在铬太

推荐答案

对我来说太... 花了几个小时寻找,但我想通了也说不定。 事实证明,如果正确的签名是:

Happened to me too... Took a few hours to find, but I figured it out eventually. Turns out that if the right signature is :

ssCNsAOxLf5vA80ldAI3M0CU2%2BW =

ssCNsAOxLf5vA80ldAI3M0CU2%2Bw=

然后AWS不接受:

ssCNsAOxLf5vA80ldAI3M0CU2 + W =

ssCNsAOxLf5vA80ldAI3M0CU2+w=

其中,唯一的区别是%2B的翻译到+

Where the only difference is the translation of %2B to '+'.

S3BotoStorage实际上得到正确的,但在编码发生在CachedFilesMixin在url方法的最后一行(返回引文结束(final_url))。 为了解决这个问题,我得出一个新的CachedFilesMixin撤消损害(我要指出,我不知道为什么会这样引文结束存在摆在首位,因此撤销可能会导致其它问题)

S3BotoStorage actually yields it correctly but the encoding happens on CachedFilesMixin in the final line of the url method (return unquote(final_url)). To fix it, I derived a new CachedFilesMixin to undo the "damage" (I should mention that I don't know why this unquote exists in the first place, so undoing it might cause other problems)

class MyCachedFilesMixin(CachedFilesMixin):
def url(self, *a, **kw):
    s = super(MyCachedFilesMixin, self).url(*a, **kw)
    if isinstance(s, unicode):
        s = s.encode('utf-8', 'ignore')
    scheme, netloc, path, qs, anchor = urlparse.urlsplit(s)
    path = urllib.quote(path, '/%')
    qs = urllib.quote_plus(qs, ':&=')
    return urlparse.urlunsplit((scheme, netloc, path, qs, anchor))

当我用code,我发现这里

希望这有助于...

这篇关于不一致SignatureDoesNotMatch亚马逊S3与Django的管道,s3boto和存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆