flexera-public / right_aws

RightScale Amazon Web Services Ruby Gems
MIT License
451 stars 175 forks source link

S3: Streaming response (get) does not work with redirect #153

Open tkoenig opened 11 years ago

tkoenig commented 11 years ago

If you are using for example the european S3 Server for your bucket location, a streaming response will fail unless you explicitly set the correct server.

I'm not sure if this is an issue, but I think at least there could be a hint in the documentation for this.

Example (not working)

s3 = RightAws::S3Interface.new(key, secret)

#Using a bucket in Ireland
s3.get(bucket, 'example.jpg') do |chunk|
  puts "got chunk"
end
I, [2012-11-26T12:15:48.100871 #35107]  INFO -- : New RightAws::S3Interface using shared connections mode
I, [2012-11-26T12:15:48.101428 #35107]  INFO -- : Opening new HTTPS connection to bucket.s3.amazonaws.com:443
I, [2012-11-26T12:15:49.063040 #35107]  INFO -- : ##### RightAws::S3Interface redirect requested: 307 Temporary Redirect #####
I, [2012-11-26T12:15:49.063101 #35107]  INFO -- :       Old location: https://bucket.s3.amazonaws.com:443/example.jpg
I, [2012-11-26T12:15:49.063128 #35107]  INFO -- :       New location: https://bucket.s3-external-3.amazonaws.com/example.jpg
I, [2012-11-26T12:15:49.063154 #35107]  INFO -- :       Request Verb: Net::HTTP::Get
I, [2012-11-26T12:15:49.063499 #35107]  INFO -- : ##### Retry #1 is being performed due to a redirect.  ####
I, [2012-11-26T12:15:49.063643 #35107]  INFO -- : Opening new HTTPS connection to bucket.s3-external-3.amazonaws.com:443

Example (working)


s3 = RightAws::S3Interface.new(key, secret, :server => 's3-external-3.amazonaws.com'})
s3.get(bucket, 'example.jpg') do |chunk|
  puts "got chunk"
end
I, [2012-11-26T12:19:29.516448 #35150]  INFO -- : New RightAws::S3Interface using shared connections mode
I, [2012-11-26T12:19:29.517062 #35150]  INFO -- : Opening new HTTPS connection to bucket.s3-external-3.amazonaws.com:443
got chunk
got chunk
...
esad commented 10 years ago

+1