6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/turbo/getter.rb', line 6
def self.from_s3(options)
bucket_name = options[:bucket]
object_name = options[:named]
settings = {}
settings[:access_key_id] = Turbo::Key.access
settings[:secret_access_key] = Turbo::Key.secret
file = ARGV[0]
puts "Establishing connection to S3"
Base.establish_connection!(
:access_key_id => settings[:access_key_id],
:secret_access_key => settings[:secret_access_key]
)
bucket = Bucket.find(bucket_name)
puts "Current bucket store: #{bucket.objects.size}"
puts "Downloading: #{file}"
open(options[:to], 'w') do |outfile|
S3Object.stream(object_name, bucket_name) do |chunk|
outfile.write chunk
end
end
end
|