aws-s3
aws-s3 copied to clipboard
S3Object.url_for does not work correctly with CNAME host-specifications.
trafficstars
:001 > AWS::S3::Base.establish_connection! :access_key_id => 'key', :secret_access_key => 'secret', :server => 'my.cname'
=> #<AWS::S3::Connection:0x3317060 @http=#<Net::HTTP my.cname:80 open=false>, @options={:access_key_id=>"key", :secret_access_key=>"secret", :server=>"my.cname", :port=>80}, @secret_access_key="secret", @access_key_id="key">
:002 > AWS::S3::S3Object.url_for 'some-file.jpg', 'my.cname'
=> "http://my.cname/my.cname/some-file.jpg?AWSAccessKeyId=key&Expires=1304600700&Signature=fCWKsMFoWhul3JNlU8eR7VPVHRs%3D"
:003 > AWS::S3::S3Object.url_for 'some-file.jpg', nil
AWS::S3::CurrentBucketNotSpecified: No bucket name can be inferred from your current connection's address (`my.cname')
from /usr/local/rvm/gems/ree-1.8.7-2011.03@global/gems/aws-s3-0.6.2/bin/../lib/aws/s3/base.rb:107:in `current_bucket'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@global/gems/aws-s3-0.6.2/bin/../lib/aws/s3/base.rb:179:in `bucket_name'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@global/gems/aws-s3-0.6.2/bin/../lib/aws/s3/object.rb:300:in `path!'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@global/gems/aws-s3-0.6.2/bin/../lib/aws/s3/object.rb:291:in `url_for'
from (irb):3
:004 > AWS::S3::Version
=> "0.6.2"
The URL returned from :002 (and presumably :003 also) should be:
http://my.cname/some-file.jpg?...
and not
http://my.cname/my.cname/some-file.jpg?...
because the bucket-name should not appear in the path since it can be inferred from the host.
I've just seen the same behavior (and problem).
+1