aws3upload 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aws3upload +26 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6169f8f558b4aff0381f5a26e74cf68fec0bcfb
|
4
|
+
data.tar.gz: d60dac73ada01c1291505906dc1341e229405e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ca097c97a7d95f0d284b748de022474be5e3e6a33da2b9da6df6f0c50e6a1a6433bffb2d8b4558d0105c0d63abceb4d82bd3d6371206a3bbe12ef313647bb4
|
7
|
+
data.tar.gz: 59d310f7033179fc80da36c748c476aad25de7671398a0375d3896330127369cf61ba794ef32540a5484ce1ba7943fb2c00c3ad383a6294417f565220d428d1f
|
data/bin/aws3upload
CHANGED
@@ -1,13 +1,32 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'aws-sdk'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: aws3upload [OPTIONS] SOURCE DEST"
|
8
|
+
opts.on('-t', '--tags KEY=VALUE,...', Array, 'Add s3 tags for object') do |tags|
|
9
|
+
options[:tags] = tags.map { |i|
|
10
|
+
i.split('=')
|
11
|
+
}.to_h.map { |k,v| {key: k, value: v} }
|
12
|
+
end
|
13
|
+
end.parse!
|
14
|
+
|
15
|
+
bucket = ENV['AWS_S3_BUCKET']
|
16
|
+
source = ARGV.shift
|
17
|
+
target = ARGV.shift
|
18
|
+
|
19
|
+
raise "Missing AWS_S3_BUCKET env variable" unless bucket
|
20
|
+
raise "Missing DEST argument" unless target
|
21
|
+
raise "Missing SOURCE argument" unless source
|
7
22
|
|
8
23
|
puts "Copy #{source} to #{bucket}:::#{target}"
|
9
24
|
|
10
|
-
s3 = Aws::S3::
|
11
|
-
|
12
|
-
|
13
|
-
|
25
|
+
s3 = Aws::S3::Client.new
|
26
|
+
File.open(source,'rb') do |file|
|
27
|
+
s3.put_object(bucket: bucket, key: target, body: file)
|
28
|
+
end
|
29
|
+
|
30
|
+
if options[:tags]
|
31
|
+
s3.put_object_tagging({bucket: bucket, key: target, tagging:{ tag_set: options[:tags] } })
|
32
|
+
end
|