aws-s3
aws-s3 copied to clipboard
Key with leading slash
Hi - was wondering whether anyone come across an issue where if you key starts with "/" , you get back AWS::S3::NoSuchKey .
Thanks,
Patrick
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.