Archive for November, 2007

15
Nov
07

Faking S3 for attachment_fu with ParkPlace

I’ve been fooling around with doing file storage on Amazon S3, and using Park Place to fake a real connection (for testing, working on the bus, saving fifteen cents, etc.)

Here are the notes I took away, using it on Leopard.

Host configuration:

$ sudo gem install -y aws-s3$ sudo gem install -y camping --source http://code.whytheluckystiff.net
$ sudo gem install -y mongrel activerecord
  2. mongrel 1.1.1 (ruby)
$ sudo gem install sqlite3-ruby --source http://code.whytheluckystiff.net
  2. sqlite3-ruby 1.2.1 (ruby)

Get parkplace:

cd /tmp && svn export http://code.whytheluckystiff.net/svn/parkplace/trunk parkplace
sudo ruby setup.rb
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/parkplace /usr/bin

Run parkplace: (this is screaming for some launchd love…)
parkplace &

Create a config/amazon_s3.yml file resembling:

development:
  bucket_name: myapp_development
  access_key_id: '44CF9590006BF252F707'
  secret_access_key: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
  server: localhost
  port: 3002
test:
  bucket_name: myapp_test
  access_key_id: '44CF9590006BF252F707'
  secret_access_key: 'OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
  server: localhost
  port: 3002
production:
  bucket_name: your_bucket_name
  access_key_id: your_access_key_id
  secret_access_key: your_secret_access_key

(I’m OK with publishing those keys because I found them in parkplace bin/parkplace.)

Make sure that parkplace and config/amazon_s3.rb agree on what port to use.

If you change your model has_attachment to reflect :storage => :s3 suddenly all access to the model accesses storage on S3 (or your localhost fake).

Fun stuff:

  • parkplace generates a ~/.parkplace/park.db that can be accessed with sqlite3>
  • sqlite3 ~/.parkplace/park.db ‘select * from parkplace_bits;’
  • Files are under ~/.parkplace/storage/
  • parkplace has a nifty console application at http://whatever.com:8080/profile

… and again:
$ sudo gem install -y aws-s3
$ sudo gem install -y camping --source http://code.whytheluckystiff.net
$ sudo gem install -y mongrel activerecord
2. mongrel 1.1.1 (ruby)
$ sudo gem install sqlite3-ruby --source http://code.whytheluckystiff.net
2. sqlite3-ruby 1.2.1 (ruby)




November 2007
M T W T F S S
    Dec »
 1234
567891011
12131415161718
19202122232425
2627282930  

Follow

Get every new post delivered to your Inbox.