title: How to get objects' keys in amazon s3 in Rails?
body: <p>I use <code>S3</code> to store some photos to send their path through <code>rails</code> to mobile clients, but when I started to send the data for a specific item in show method I used this code with <code>aws-sdk</code> gem to check where is the photos and get their path</p>
  
  <pre><code>s3 = Aws::S3::Resource.new(
        access_key_id: 'askdlkasdmkmakml',
        secret_access_key: 'aklsdmkmasldkmasmdlmasdl',
        region: 'ap-southeast-1'
      )
  
      images = []
      s3.bucket('my-pics').objects.find_all do |object| 
          images &lt;&lt; object.key if object.key.include?(self.barcode_number})
      end
  </code></pre>
  
  <blockquote>
    <p>this code I tested it with ruby not rails and I get this as result:</p>
  </blockquote>
  
  <p><code>photos/9000101044393/1.jpg</code>
  <code>photos/9000101044393/2.jpg</code></p>
  
  <p>but when I use this code inside <code>rails</code> I got all these stuff</p>
  
  <pre><code>[#&lt;Aws::S3::ObjectSummary:0x007fe348713170 @bucket_name="my-pics",     
  @key="photos/9000101044393/1.jpg", @data=#&lt;struct     
  Aws::S3::Types::Object key="photos/9000101044393/1.jpg",     
  last_modified=2018-03-01 05:14:57 UTC,     
  etag="\"ee4540acc2a5bfc948507e0927e9dd1b\"", size=140119,     
  storage_class="STANDARD", owner=#&lt;struct Aws::S3::Types::Owner 
  display_name="mohammed.eliass",     
  id="06bf2e3c37f83d96de16b13fc00efc20a097988edd1d4"&gt;&gt;, @client=#    
  &lt;Aws::S3::Client&gt;&gt;, #&lt;Aws::S3::ObjectSummary:0x007fe348713008     
  @bucket_name="my-pics", @key="photos/9000101044393/2.jpg", @data=#   
  &lt;struct Aws::S3::Types::Object key="photos/9000101044393/2.jpg",    
  last_modified=2018-03-01 05:14:57 UTC,    
  etag="\"b13dc7b1a516fee5ed15bccc57e\"", size=33132,    
  storage_class="STANDARD", owner=#&lt;struct Aws::S3::Types::Owner    
  display_name="mohammed.eliass",  id="06bf2e3c37f83d96de16b13fc0adasdaddskfl88edd1d449d85b7157d95bdf334"&gt;&gt;,
  
  @client=#&lt;Aws::S3::Client&gt;&gt;, #&lt;Aws::S3::ObjectSummary:0x007fe348712ef0     
  @bucket_name="my-pics", @key="photos/9000101044430/1.jpg", @data=#    
  &lt;struct Aws::S3::Types::Object key="photos/9000101044430/1.jpg",     
  last_modified=2018-03-01 05:14:59 UTC,     
  etag="\"308ab75c98257b821469b4b93e9ca8f8\"", size=141066,    
  storage_class="STANDARD", owner=#&lt;struct Aws::S3::Types::Owner    
  display_name="mohammed.eliass"]
  </code></pre>
  
  <p>So any ideas how should I get rid of all this and get only the keys?</p>