Class: FileConvert::Bucket
- Inherits:
-
Object
- Object
- FileConvert::Bucket
- Defined in:
- lib/file_convert/bucket.rb
Instance Method Summary collapse
- #download(key) ⇒ Object
-
#initialize(config) ⇒ Bucket
constructor
A new instance of Bucket.
Constructor Details
#initialize(config) ⇒ Bucket
Returns a new instance of Bucket.
5 6 7 8 9 10 11 12 |
# File 'lib/file_convert/bucket.rb', line 5 def initialize(config) AWS::S3::Base.establish_connection!( access_key_id: config.s3_key, secret_access_key: config.s3_secret ) @bucket = AWS::S3::Bucket.find('clearfit-thumbnails-development') end |
Instance Method Details
#download(key) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/file_convert/bucket.rb', line 14 def download(key) temp_file = Converter.get_a_temp_file key file_with_key = @bucket[key] raise "There is no file with the key [#{key}]" if file_with_key.nil? File.open(temp_file, 'w') { |file| file.write(file_with_key.value) } temp_file end |