qoobaa / s3

Library for accessing S3 objects and buckets, supports EU and US buckets
MIT License
258 stars 112 forks source link

Problem with ssl: Net::HTTPMovedPermanently #90

Closed augnustin closed 10 years ago

augnustin commented 10 years ago

I recently moved my app to full ssl encryption.

As I was using S3, I updated the way I was using this beautiful gem the following way:

      amazon = S3::Service.new(access_key_id: <access_key_id>, secret_access_key: <secret_access_key>)

# to

      amazon = S3::Service.new(access_key_id: <access_key_id>, secret_access_key: <secret_access_key>, use_ssl: true)

But since then, I can't use it anymore. Forking the gem and debugging it locally, I get a Net::HTTPMovedPermanently error containing the following info:

--- !ruby/object:Net::HTTPMovedPermanently
http_version: '1.1'
code: '301'
message: Moved Permanently
header:
  x-amz-request-id:
  - 214B424AFBF22E4A
  x-amz-id-2:
  - iE0X0tGyQKJ0DcQcxosrWfYv7vfGxO+e2zwyMpbTvtIgnYqzeOqXpZQhvE6outSw
  content-type:
  - application/xml
  transfer-encoding:
  - chunked
  date:
  - Tue, 22 Apr 2014 09:15:07 GMT
  server:
  - AmazonS3
body: 
read: true
socket: 
body_exist: false

Any clue to help? Thanks

augnustin commented 10 years ago

The answer was here: http://stackoverflow.com/questions/13691881/301-moved-permanently-after-s3-uploading

I changed the default host to HOST = "s3-eu-west-1.amazonaws.com" (in s3.rb) as I am hosting in Europe. It should be in the options as it is in the SO post for the fog gem, and handle the correct switch of url when needed.

Thanks for awesome gem again!