peterknife / boto

Automatically exported from code.google.com/p/boto
0 stars 0 forks source link

Can't copy keys with Spaces in them #461

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make a key in s3 with a space in the name
2. Run the k.copy("someKey", k.bucket.name) command
3. OR run bucket.copy("somekey", bucket.name, "source key name")

What is the expected output? What do you see instead?

You get a "404 not found" error on the source key. I believe this only occurs 
when you have spaces in the key source name, and the problem is most likely 
caused by wrapping the key name in a urllib.quote function. 

I believe this can be resolved by simply changing line 443  of s3/bucket.py and 
removing the urllib.quote function. In my test this worked, but I don't know if 
it was placed there for a reason or not, so I'm not checking that change in 
just yet.

Please use labels and text to provide additional information.

s3, copy key

Original issue reported on code.google.com by cmo...@newstex.com on 4 Oct 2010 at 5:04

GoogleCodeExporter commented 9 years ago
Can this be solved by using the OrdinaryCallingFormat rather than the standard 
one?

Original comment by Mitch.Ga...@gmail.com on 5 Oct 2010 at 6:00

GoogleCodeExporter commented 9 years ago
No, I guess given where it is that would have no effect whatsoever.  I need to 
walk back through the commits and see when that call to urllib.quote was added 
and why.

Original comment by Mitch.Ga...@gmail.com on 5 Oct 2010 at 6:04

GoogleCodeExporter commented 9 years ago
Here's where the change was introduced:

http://github.com/boto/boto/commit/bd35cacff31babec3e24bfdaf46adc4cb8547fb1

To fix this issue:

http://code.google.com/p/boto/issues/detail?id=306

Original comment by Mitch.Ga...@gmail.com on 5 Oct 2010 at 6:19

GoogleCodeExporter commented 9 years ago
How about if you change the line from:

        src = '%s/%s' % (src_bucket_name, urllib.quote(src_key_name))

to:

        src = '%s/%s' % (src_bucket_name, urllib.quote(src_key_name, safe='/ '))

Original comment by Mitch.Ga...@gmail.com on 5 Oct 2010 at 6:39

GoogleCodeExporter commented 9 years ago
So yes, this does resolve the issue at hand, but this also brings up another 
issue. This orignal commit fixed the issue of "+" not working in the 
destination key, but now it doesn't work in the Source Key. that is to say if I 
try to copy a key that has a "+" in it using this method, I get the 404 error 
on the key.

Original comment by cmo...@newstex.com on 8 Oct 2010 at 7:33

GoogleCodeExporter commented 9 years ago
I think this has been fixed in:

https://github.com/boto/boto/commit/2438b831d8499f21de5e66dc2fcd3ce6ac0be643

Original comment by Mitch.Ga...@gmail.com on 18 Mar 2011 at 9:26