Project

ThreeStore

0.0
No commit activity in last 3 years
No release in over 3 years
Get files from a url and store them on s3
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2.2
~> 2.5.0

Runtime

>= 0
 Project Readme

ThreeStore¶ ↑

(More info)

Tutorial¶ ↑

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:

=> 'http://s3.amazonaws.com/my-bucket/picture.png'

The destination path is constructed thus: s3.amazonaws.com/ + bucket name + key

FAQ¶ ↑

“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!