class Nab::S3Adapter

Attributes

strip_dirs[RW]
write_adapter[RW]

Public Class Methods

new() click to toggle source
# File lib/nab/adapters/s3.rb, line 7
def initialize
  AWS.config
  @write_adapter = FileWriter
  @strip_dirs = false
end

Public Instance Methods

get(uri,destination) click to toggle source
# File lib/nab/adapters/s3.rb, line 13
def get(uri,destination)
  bucket_name = uri.host
  s3          = AWS::S3.new
  bucket      = s3.buckets[bucket_name]
  asset       = bucket.objects[Util.path_from_uri(uri)]
  asset_name  = Util.path_from_uri(uri,strip_dirs)
  Nab::Log.info "Retrieving #{File.join(bucket_name,asset_name)}"
  store       = write_adapter.new(destination, asset_name)

  asset.read { |chunk| store.write chunk }
  store.close
end