Class: S3Batch::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/s3batch/batch_upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket, dir, pattern, options = {}) ⇒ Upload

Returns a new instance of Upload.



25
26
27
28
29
30
# File 'lib/s3batch/batch_upload.rb', line 25

def initialize(bucket, dir, pattern, options = {})
  @bucket = bucket
  @dir = dir.end_with?('/') ? dir : dir + "/"
  @pattern = pattern
  @options = options
end

Class Method Details

.run(s3id, s3key, bucket, dir, pattern = "**/*") ⇒ Object



40
41
42
43
44
45
# File 'lib/s3batch/batch_upload.rb', line 40

def self.run s3id, s3key, bucket, dir, pattern = "**/*"
  EM.run {
    items = S3Batch::Upload.new bucket, dir, pattern, :aws_access_key_id => s3id, :aws_secret_access_key => s3key, :protocol => 'http', :permissions => 'public-read'
    items.upload 
  }
end

Instance Method Details

#upload(request_options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/s3batch/batch_upload.rb', line 32

def upload request_options = {}
  item = Happening::S3::Item.new(@bucket, '', @options)
  item.get { |response|
    keys = parse_keys(response.response)
    check_md5_and_upload keys
  }
end