Class: OpsPreflight::S3Transfer
- Inherits:
-
Object
- Object
- OpsPreflight::S3Transfer
- Defined in:
- lib/ops_preflight/s3_transfer.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(bucket, file) ⇒ S3Transfer
constructor
A new instance of S3Transfer.
- #upload ⇒ Object
Constructor Details
#initialize(bucket, file) ⇒ S3Transfer
Returns a new instance of S3Transfer.
6 7 8 9 |
# File 'lib/ops_preflight/s3_transfer.rb', line 6 def initialize(bucket, file) @bucket = bucket @file = file end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
3 4 5 |
# File 'lib/ops_preflight/s3_transfer.rb', line 3 def bucket @bucket end |
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/ops_preflight/s3_transfer.rb', line 4 def file @file end |
Instance Method Details
#download ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ops_preflight/s3_transfer.rb', line 24 def download basename = File.basename(file) remote_file = directory.files.get(basename) File.open(file, 'w') do |local_file| local_file.write(remote_file.body) end end |
#upload ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ops_preflight/s3_transfer.rb', line 11 def upload basename = File.basename(file) remote_file = directory.files.head(basename) remote_file.destroy if remote_file directory.files.create( :key => basename, :body => File.open(file), :public => false ) end |