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

S3Object.url_for does not work correctly with CNAME host-specifications.

Open nickgrim opened this issue 14 years ago • 2 comments
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.

nickgrim avatar May 05 '11 13:05 nickgrim

I've just seen the same behavior (and problem).

58bits avatar Jun 17 '11 22:06 58bits

+1

friendofasquid avatar Sep 07 '12 12:09 friendofasquid