Module: Jack::Tasks::S3
- Defined in:
- lib/jack/tasks/s3.rb
Instance Method Summary collapse
- #default_s3_bucket ⇒ Object
- #delete_from_s3(name, bucket = nil) ⇒ Object
- #download_from_s3(name, bucket = nil) ⇒ Object
- #s3_working_path ⇒ Object
- #store_in_s3(name, filename, bucket = nil, options = {}) ⇒ Object
Instance Method Details
#default_s3_bucket ⇒ Object
35 36 37 |
# File 'lib/jack/tasks/s3.rb', line 35 def default_s3_bucket @default_s3_bucket end |
#delete_from_s3(name, bucket = nil) ⇒ Object
29 30 31 32 33 |
# File 'lib/jack/tasks/s3.rb', line 29 def delete_from_s3(name, bucket = nil) bucket ||= default_s3_bucket logger.info("[S3] Deleting #{name} from #{bucket}") AWS::S3::S3Object.delete name, bucket end |
#download_from_s3(name, bucket = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jack/tasks/s3.rb', line 16 def download_from_s3(name, bucket = nil) bucket ||= default_s3_bucket logger.info("[S3] Downloading #{name} from #{bucket}") Dir.chdir s3_working_path do open name, 'w' do |file| AWS::S3::S3Object.stream name, bucket do |chunk| file.write chunk end end end File.join s3_working_path, name end |
#s3_working_path ⇒ Object
39 40 41 |
# File 'lib/jack/tasks/s3.rb', line 39 def s3_working_path @s3_working_path end |
#store_in_s3(name, filename, bucket = nil, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/jack/tasks/s3.rb', line 6 def store_in_s3(name, filename, bucket = nil, = {}) if bucket.is_a?(Hash) = bucket bucket = nil end bucket ||= default_s3_bucket logger.info("[S3] Storing #{name} in #{bucket} from #{filename}") AWS::S3::S3Object.store name, open(filename), bucket, end |