I'm trying to figure out how to upload a file to S3 with the v2 API and ruby 2.1.5, and seeing a surprising degree of resistance. Is this expected to work?
#!/usr/bin/env ruby
require 'aws-sdk'
credential = Aws::Credentials.new('…', '…')
s3 = Aws::S3::Client.new(credentials: credential, region: "us-west-2")
test_object = Aws::S3::Object.new("existing-bucket-name", "test-filename", {region: "us-west-2"})
result = test_object.upload_file("/path/to/test/upload.txt")
Here's how it blows up:
/Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/signers/s3.rb:43:in `sign': undefined method `session_token' for nil:NilClass (NoMethodError)
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/signers/s3.rb:27:in `sign'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_request_signer.rb:45:in `apply_v2_signature'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_request_signer.rb:29:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/xml/error_handler.rb:8:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_request_signer.rb:123:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_redirects.rb:15:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/retry_errors.rb:88:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_md5s.rb:33:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_expect_100_continue.rb:21:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_bucket_dns.rb:31:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/rest_body_handler.rb:9:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/user_agent.rb:12:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/restful_bindings.rb:13:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/endpoint.rb:35:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/param_validation.rb:22:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/param_conversion.rb:22:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/plugins/response_target.rb:18:in `call'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.24/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-resources-2.0.24/lib/aws-sdk-resources/services/s3/file_uploader.rb:42:in `block in put_object'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-resources-2.0.24/lib/aws-sdk-resources/services/s3/file_uploader.rb:49:in `open_file'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-resources-2.0.24/lib/aws-sdk-resources/services/s3/file_uploader.rb:41:in `put_object'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-resources-2.0.24/lib/aws-sdk-resources/services/s3/file_uploader.rb:34:in `upload'
from /Users/irons/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/aws-sdk-resources-2.0.24/lib/aws-sdk-resources/services/s3/object.rb:102:in `upload_file'
from ./upload-test.rb:8:in `<main>'
I'm not finding any help in the API documentation for dealing with this problem. I don't know how I managed to misjudge the difficulty of uploading a file by an order of magnitude, but it feels like a feat.
I'm trying to figure out how to upload a file to S3 with the v2 API and ruby 2.1.5, and seeing a surprising degree of resistance. Is this expected to work?
Here's how it blows up:
I'm not finding any help in the API documentation for dealing with this problem. I don't know how I managed to misjudge the difficulty of uploading a file by an order of magnitude, but it feels like a feat.