title: How to upload an image to Amazon S3 into a folder in ruby?
body: <p>I am trying to do it like this:</p>
  
  <pre><code>AWS.config(
        :access_key_id =&gt; '...', 
        :secret_access_key =&gt; '...'
      )
      s3 = AWS::S3.new
      bucket_name = 'bucket_name'
  key = "#{File.basename(avatar_big)}"
  s3.buckets[bucket_name].objects[key].write(:file =&gt; avatar_big_path)
  </code></pre>
  
  <p>This working well for a file, the file is uploaded to the root of the set up bucket.</p>
  
  <p>However, how to upload it into the foloder <strong>photos</strong> that is located in root?</p>
  
  <p>I've tried </p>
  
  <pre><code>key = "photos/#{File.basename(avatar_big)}"
  </code></pre>
  
  <p>but this doesn't work.</p>
  
  <p><strong>EDIT: error message</strong>
  <img src="https://i.stack.imgur.com/ZHUlP.png" alt="enter image description here"></p>
  
  <p>Thank you</p>