Class: Capriza::Aws::S3Upload
- Inherits:
-
Object
- Object
- Capriza::Aws::S3Upload
- Defined in:
- lib/capriza-aws.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(options = {}) ⇒ S3Upload
constructor
A new instance of S3Upload.
- #upload ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ S3Upload
Returns a new instance of S3Upload.
93 94 95 96 97 |
# File 'lib/capriza-aws.rb', line 93 def initialize( = {}) @options = AWS.config(@options[:config]) @s3 = AWS::S3.new(:s3_endpoint => @options[:config]['s3_endpoint']) end |
Instance Method Details
#delete ⇒ Object
107 108 109 110 |
# File 'lib/capriza-aws.rb', line 107 def delete puts "deleting #{@options['dir']}" @s3.buckets[@options[:bucket]].objects.with_prefix(@options[:dir] + '/').delete_all end |
#upload ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/capriza-aws.rb', line 99 def upload Dir.glob("#{@options[:dir]}/**/*").each do |file| puts "starting upload of #{file} to #{@options[:bucket]}" @s3.buckets[@options[:bucket]].objects[file].write(File.read(file), @options[:file_options] || {} ) unless File.directory?(file) puts "completed upload of #{file} to #{@options[:bucket]}" end end |