title: Uploading a file using the Ruby SDK to Amazon S3
body: <p>I am trying to upload a file. A simple hello.txt.  I was following the docs, and I am unable to upload it to my bucket. </p>
  
  <pre><code>#  START AWS CLIENT
  
  s3 = Aws::S3::Resource.new
  bucket = s3.bucket(BUCKET_NAME)
  
  begin
  
    s3.buckets[BUCKET_NAME].objects[KEY].write(:file =&gt; FILE_NAME)
    puts "Uploading file #{FILE_NAME} to bucket #{BUCKET_NAME}."
  
    bucket.objects.each do |obj|
      puts "#{obj.key} =&gt; #{obj.etag}"
    end
  
  rescue Aws::S3::Errors::ServiceError
    # rescues all errors returned by Amazon Simple Storage Service
  end
  </code></pre>
  
  <p>I was following <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpRuby.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpRuby.html</a></p>
  
  <p>The error: </p>
  
  <blockquote>
    <p>➜  s3-tester  ruby main.rb
    /Users/.rvm/gems/ruby-2.1.1/gems/aws-sdk-resources-2.0.34/lib/aws-sdk-resources/collection.rb:79:in
    'method_missing: undefined method []' for
    '<code>&lt;Aws::Resources::Collection:0x000001031e5100&gt;</code> (NoMethodError)'     from 'main.rb:18:in <code>&lt;main&gt;</code>'</p>
  </blockquote>