To store something on s3:
Perhaps you are storing your s3 secret access key id and secret access key as environment variables - you can access them like this:
@store = ThreeStore.new(ENV['S3_KEY'], ENV['S3_SECRET'], 'my-bucket')
If you are storing aforementioned credentials in a yaml file:
@yaml = 'path_to_my_yaml_file.yml' @store = ThreeStore.new(@yaml[:access_key_id], @yaml[:secret_access_key], 'my-bucket')
To upload a file, use ThreeStore#store_on_s3:
@store.store_on_s3(:url => 'http://example.com/assets/picture.png', :key => 'picture.png', :content_type => 'image/png', :access => 'public-read')
Options to pass to store_on_s3:
* :url, the url or path from which to fetch the file * :key, the that you wish your object to have on s3 * :content_type (optional) - the content type will be inferred from the file extension, but it can be passed in if needed * :access (optional) - Default access is private, but can be set to 'public-read' and maybe even 'public-write'
(For more information on access level options, look in the Amazon S3 docs: aws.amazon.com/documentation)
This will return your file's new location on s3:
The destination path is constructed thus: s3.amazonaws.com/ + bucket name + key
“ThreeStore”? That's stupid. Why isn't it called “3store”? That's much cooler.
Because modules can't start with a number. Jeez, lay off! And get off my lawn!