21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/s3-batch.rb', line 21
def upload(dir=nil)
@root = dir
bucket
acl
total = 0
files_to_upload.each do |file|
total += File.size(File.join(@root, file))
end
progress = ProgressBar.new('Upload', total)
files_to_upload.each do |file|
object = bucket.objects[file]
progress.inc File.size(File.join(@root, file))
if object.exists?
next
end
object.write(
:file => File.join(@root, file),
:acl => acl,
:storage_class => :standard,
:cache_control => 'max-age=315360000')
end
progress.finish
end
|