title: How do I read files, in Rails, (images/text) from Amazon s3 that were uploaded manually?
body: <p>First, I'm very new to Rails, and Stack Overflow, and currently bushwhacking my way through the learning curve, so I apologize if my post is laughably noobish.  Here's my problem:</p>
  
  <p>I'm trying to build a blog from scratch using Amazon s3 to store resources, such as all the images and text.  I have no need for Users uploading stuff to the site, so I figure I can just upload everything manually to s3 using their console at console.aws.amazon.com.  I'm trying to code Rails to read folders from my s3 bucket and then point the images/text to the right spots in the database.  For example, I could make a folder called "Post1" in s3, then my Rails app reads the URL of everything from inside that folder and points it to post1 in the database, then I can simply call up the image URL, or text, in the view and, theoretically, display it.  My question is, how do I get my app to read s3 folders?</p>
  
  <p>I know I'm probably reinventing the wheel here, but my goal is also to learn Rails.  Thanks everyone in advance.  You can find <a href="https://github.com/ScatbodJudo/PoorRidersAlmanac" rel="nofollow">my project</a> on GitHub.</p>
  
  <p>My blog model:</p>
  
  <pre><code>class BlogPost &lt; ActiveRecord::Base
    has_attached_file :download,
                      :storage =&gt; :s3,
                      :s3_credentials =&gt; Proc.new{|a| a.instance.s3_credentials }
  
    def s3_credentials
      {:bucket =&gt; "S3_BUCKET_NAME", :access_key_id =&gt; "AWS_ACCESS_KEY_ID", :secret_access_key =&gt; "AWS_SECRET_ACCESS_KEY"}
    end
  
  end
  </code></pre>
  
  <p>Here is my blog controller:</p>
  
  <pre><code>class BlogController &lt; ApplicationController
      before_action :load_posts
  
  
        def index  #this method puts all the stuff pulled from 'load_posts' and packages it nicely in a instanced variable
      @blogPosts = BlogPost.all
      end
  
      def load_posts  #this method should pull posts from AWS s3 and add them to the database (like magic)
  
      end
  
  end
  </code></pre>
  
  <p>I'm sure there are gaping holes in my code...like something to actually talk to s3.  I know the bulk of what I want to do probably goes in my model.  I feel really stuck.  I'm hoping there's some simple, magical Ruby method that I can use, like s3.file.read or something.  Another option would be to create a form for myself, as though I'm a User, that connects everything together in the database, then uploads to s3.  Yet, I've read people run into issues, like dynos timing out, when they try to upload large files (like big images) through heroku and onto s3.  I've read tutorials on how to upload directly to s3, but I might as well skip that process and just click the 'upload' button on the s3 console.  Anything will help.  Thanks again all.</p>