Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 broken in Ruby 2.0.0 #192

Closed
matthiassiegel opened this issue Mar 12, 2013 · 3 comments
Closed

S3 broken in Ruby 2.0.0 #192

matthiassiegel opened this issue Mar 12, 2013 · 3 comments

Comments

@matthiassiegel
Copy link

Not sure you're officially supporting Ruby 2.0.0 but I ran into a problem that only happens in Ruby 2.0.0 but with 1.9.3 it works fine.

In my app I have a piece of code that uses the gem to upload to S3:

object.write(:content_length => data.size) do |buffer, bytes|
  buffer.write(data.read(bytes))
end

Like I said with 1.9.3 it works fine but in 2.0.0 it fails with the following trace:

wrong number of arguments (2 for 0..1)
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/s3/data_options.rb:156:in `read'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http/generic_request.rb:202:in `copy_stream'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http/generic_request.rb:202:in `send_request_with_body_stream'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http/generic_request.rb:132:in `exec'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:1403:in `block in transport_request'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:1402:in `catch'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:1402:in `transport_request'
/Users/Matt/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/http.rb:1375:in `request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/net/http/connection_pool/session.rb:64:in `request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/net/http/connection_pool.rb:173:in `block in request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/net/http/connection_pool.rb:194:in `session_for'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/net/http/connection_pool.rb:171:in `request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/net/http/connection_pool/connection.rb:173:in `request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/http/net_http_handler.rb:66:in `handle'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:231:in `block in make_sync_request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:260:in `retry_server_errors'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:227:in `make_sync_request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:472:in `block (2 levels) in client_request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:355:in `log_client_request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:441:in `block in client_request'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:337:in `return_or_raise'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/core/client.rb:440:in `client_request'
(eval):3:in `put_object'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/s3/s3_object.rb:1656:in `write_with_put_object'
/Users/Matt/.rvm/gems/ruby-2.0.0-p0/gems/aws-sdk-1.8.4/lib/aws/s3/s3_object.rb:603:in `write'
/Users/Matt/Sites/path/to/my/app/lib/s3.rb:45:in `write'
@trevorrowe
Copy link
Member

Thank you for reporting the issue. Please try to use the following form:

object.write(data) # data should be an io-like object and respond to #size and #read

This is the preferred way to upload an IO-like object via S3Object#write. The block form is deprecated. That said, we do support Ruby 2 and I'll take a look at why this is failing.

@trevorrowe
Copy link
Member

Closing this issue for now. Currently it appears AWS::S3 works fine with Ruby 2 (with the exception of this deprecated #write behavior). Please re-open if you encounter other issues.

@trevorrowe
Copy link
Member

I am re-opening this issue. A related issue (#215) trigger the same bug. I'm going to be pushing a fix that should resolve both. That said, I still recommend not using this block form for #write.

@trevorrowe trevorrowe reopened this Apr 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants