title: Aws S3 connection with specific path
body: <p>I am trying to list and download folders from a bucket on path eg:"aaa/bbb/" using the aws-sdk gem v2. However I can't figure out how to do it.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>require 'aws-sdk'
  
  Aws.config.update({
    region: 'us-west-2',
    credentials: Aws::Credentials.new('akid', 'secret')
  })        
  
  s3 = Aws::S3::Resource.new
  
  # reference an existing bucket by name
  bucket = s3.bucket('aaa')
  
  bucket.objects(prefix: '/bbb/').each do |folder|
    p folder
  end
  </code></pre>
  
  <p>It says: <strong>Access Denied (Aws::S3::Errors::AccessDenied)</strong></p>
  
  <p>But, if I use the command line AWS CLI instead, and execute:</p>
  
  <pre><code>aws s3 ls aaa/bbb/
  </code></pre>
  
  <p>it works...</p>
  
  <p>Any suggestion?</p>
  
  <p>Many thanks.</p>