aws-s3 icon indicating copy to clipboard operation
aws-s3 copied to clipboard

Key with leading slash

Open pdtpatrick opened this issue 12 years ago • 1 comments

Hi - was wondering whether anyone come across an issue where if you key starts with "/" , you get back AWS::S3::NoSuchKey .

Thanks,

Patrick

pdtpatrick avatar Dec 24 '12 06:12 pdtpatrick

Yep, just hit that myself. S3Object.find works fine, but .value returns NoSuchKey

Problem appears to be in lib/aws/s3/object.rb path! This bit: '/' << File.join(bucket_name(bucket), name)

File.join strips leading slashes, leading to the following unexpected result: irb(main):110:0> File.join "something", "something2" => "something/something2" irb(main):111:0> File.join "something", "/something2" => "something/something2"

I worked around it like so: AWS::S3::S3Object.get("/bucketname//subdir/myfile")

Basically you have to form the path yourself to work around this bug.

rborkows avatar Aug 07 '13 16:08 rborkows