# Best practice for loading aws s3 library on startup

**URL:** <https://www.ruby-forum.com/t/best-practice-for-loading-aws-s3-library-on-startup/89345>\
**Category:** Rails\
**Created:** [March 19, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/best-practice-for-loading-aws-s3-library-on-startup/89345 "2007-03-19T18:36:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan\_kuwachi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dfb087/32.png) [@dan\_kuwachi](https://www.ruby-forum.com/u/dan_kuwachi)\
**Post date:** [March 19, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/best-practice-for-loading-aws-s3-library-on-startup/89345/1 "2007-03-19T18:36:36Z")

</div>

Currently I have followed these instructions to get aws s3 working in  
my rails app

[http://developer.amazonwebservices.com/connect/entry.jspa?entryID=608](http://developer.amazonwebservices.com/connect/entry.jspa?entryID=608)

But its a little messy as a lot of the file uploading is actually done  
in the controller when I think it should be done in the model.  
Currently its done like this

class PhotoController \< ApplicationController  
before\_filter :login\_required  
layout ‘scaffold’

#load model  
model :s3\_model

#create S3::AWS handle  
S3Model.init(@config\_file)

The current files to load in the aws are:  
/lib/S3.rb (ruby library to connect to aws)  
/model/s3\_model.rb

What I would like to do is put all of the aws s3 calls in the model  
when uploading a photo. I’m thinking instead to do this…

class ApplicationController \< ActionController::Base  
include S3  
model :s3\_model

#create S3::AWS handle  
S3Model.init(@config\_file)

But if I do this… this would only given accessibility to the aws  
handler in the controller and not the model right?

If I had a class ProfilePicture \< ActiveRecord::Base how would I give  
the aws handler visibility there?

thanks in advance!  
-dan
