Amazon S3 Python S3Boto 403 Forbidden When Signature Has + sign

2024/9/24 17:18:12

I am using Django and S3Boto and whenever a signature has a '+' sign in it, I get a 403 Forbidden. If there is no '+' sign in the signature, I get the resource just fine. What could be wrong here?

UPDATE:

The repo is at : https://github.com/boto/boto

the files concerned are:

boto/utils.py
boto/s3/connection.py

NOTE: I am quite new to Python. I tried modifying the code but I still can't get the encoding done properly.

Answer

I'm a little short on time (as it's 1:30am) so unfortunately I do not have a code sample for you yet, but I believe this is because the value + in a URL should be encoded. So from github, your url of...

https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=+tahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA

should really be

https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=%2BtahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA

(Note: I replaced the + with %2B)

See http://www.w3schools.com/tags/ref_urlencode.asp

To fix the code, I would add an URLEncoding function where it builds the URL query string.

https://en.xdnf.cn/q/71678.html

Related Q&A

List comparison of element

I have a question and it is a bit hard for me to explain so I will be using lots of examples to help you all understand and see if you could help me.Say I have two lists containing book names from best…

Partition pyspark dataframe based on the change in column value

I have a dataframe in pyspark. Say the has some columns a,b,c... I want to group the data into groups as the value of column changes. SayA B 1 x 1 y 0 x 0 y 0 x 1 y 1 x 1 yThere will be 3 grou…

Error group argument must be None for now in multiprocessing.pool

Below is my python script.import multiprocessing # We must import this explicitly, it is not imported by the top-level # multiprocessing module. import multiprocessing.pool import timefrom random impor…

Making the diamond square fractal algorithm infinite

Im trying to generate an infinite map, as such. Im doing this in Python, and I cant get the noise libraries to correctly work (they dont seem to ever find my VS2010, and doing it in raw Python would be…

How do I generate coverage xml report for a single package?

Im using nose and coverage to generate coverage reports. I only have one package right now, ae, so I specify to only cover that: nosetests -w tests/unit --with-xunit --with-coverage --cover-package=aeA…

Asynchronous URLfetch when we dont care about the result? [Python]

In some code Im writing for GAE I need to periodically perform a GET on a URL on another system, in essence pinging it and Im not terribly concerned if the request fails, times out or succeeds.As I bas…

Python: How to fill out form all at once with splinter/Browser?

Currently, I’m filling out the form on a site with the following:browser.fill(‘form[firstname]’, ‘Mabel’) browser.fill(‘form[email]’, ‘[email protected]’) browser.select(‘form[color]’, ‘yel…

Dump elementtree into xml file

I created an xml tree with something like thistop = Element(top) child = SubElement(top, child) child.text = some texthow do I dump it into an XML file? I tried top.write(filename), but the method doe…

Crash reporting in Python

Is there a crash reporting framework that can be used for pure Python Tkinter applications? Ideally, it should work cross-platform.Practically speaking, this is more of exception reporting since the P…

Python SocketServer

How can I call shutdown() in a SocketServer after receiving a certain message "exit"? As I know, the call to serve_forever() will block the server.Thanks!