zzuligy / bucket_head

Gem to hit URI's and stick their contents on S3

Home Page:http://github.com/john/bucket_head/tree/master

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BucketHead

BucketHead grabs the contents of a URI–an image, html or xml file, whatever–and sticks them on S3. It requires either the RightAWS or AWS/S3 libraries. If both are present it uses RightAWS.

Install:

sudo gem install john-bucket_head-0.1.0 --source http://gems.github.com

Usage:

Make a hash available in your environment called AWS_CREDENTIALS holding, yes, your AWS credential. In Rails you can create a config/initializers/amazon_credentials.rb file containing:

AWS_CREDENTIALS = { :access_key => 'your-key-goes-here',
                    :secret_access_key => 'your-top-secret-key-goes-here'}

Then you can do something like t:

BucketHead.set_bucket_name('your-bucket')
BucketHead.put( :uri => 'http://wordie.org/', :key => 'fake-wordie.html')

That would result in the source of wordie.org/ being uploaded to: your-bucket.s3.amazonaws.com/fake-wordie.html

By default buckets and anything put in them have ‘public-read’ access. You can set bucket permissions, if, prior to bucket creation, you call:

BucketHead.set_bucket_access( 'public-read|private|public-read-write|authenticated-read')

You can set access on individual objects within buckets with an ‘:access’ argument:

BucketHead.put( :uri => 'http://wordie.org/', :key => 'fake-wordie.html', :access => 'private')

BucketHead will try to base the content type on what it finds at the :uri, but you can set it explicitly if you want:

BucketHead.put( :uri => 'http://wordie.org/', :key => 'fake-wordie.html', :access => 'private', :content_type => 'text/html')

Copyright © 2009 John McGrath, released under the MIT License. See LICENSE for details.

About

Gem to hit URI's and stick their contents on S3

http://github.com/john/bucket_head/tree/master

License:MIT License


Languages

Language:Ruby 100.0%