我有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,我发现这里
希望这有助于...