s3cp 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/lib/s3cp/s3cp.rb +1 -13
- data/lib/s3cp/s3up.rb +2 -14
- data/lib/s3cp/utils.rb +13 -0
- data/lib/s3cp/version.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/lib/s3cp/s3cp.rb
CHANGED
@@ -207,19 +207,7 @@ def log(msg)
|
|
207
207
|
puts msg if @verbose
|
208
208
|
end
|
209
209
|
|
210
|
-
|
211
|
-
headers = {}
|
212
|
-
header_array.each do |header|
|
213
|
-
header_parts = header.split(": ", 2)
|
214
|
-
if header_parts.size == 2
|
215
|
-
headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
|
216
|
-
else
|
217
|
-
log("Header ignored because of error splitting [#{header}]. Expected colon delimiter; e.g. Header: Value")
|
218
|
-
end
|
219
|
-
end
|
220
|
-
headers
|
221
|
-
end
|
222
|
-
@headers = headers_array_to_hash(options[:headers])
|
210
|
+
@headers = S3CP.headers_array_to_hash(options[:headers])
|
223
211
|
|
224
212
|
def with_headers(msg)
|
225
213
|
unless @headers.empty?
|
data/lib/s3cp/s3up.rb
CHANGED
@@ -54,19 +54,7 @@ unless ARGV.size > 0
|
|
54
54
|
exit
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
headers = {}
|
59
|
-
header_array.each do |header|
|
60
|
-
header_parts = header.split(": ", 2)
|
61
|
-
if header_parts.size == 2
|
62
|
-
headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
|
63
|
-
else
|
64
|
-
log("Header ignored because of error splitting [#{header}]. Expected colon delimiter; e.g. Header: Value")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
headers
|
68
|
-
end
|
69
|
-
@headers = headers_array_to_hash(options[:headers])
|
57
|
+
@headers = S3CP.headers_array_to_hash(options[:headers])
|
70
58
|
|
71
59
|
url = ARGV[0]
|
72
60
|
|
@@ -77,7 +65,6 @@ fail "Your URL looks funny, doesn't it?" unless bucket
|
|
77
65
|
|
78
66
|
# copy all of STDIN to a temp file
|
79
67
|
temp = Tempfile.new('s3cp')
|
80
|
-
f = File.new("newfile2.zip", "wb")
|
81
68
|
while true
|
82
69
|
begin
|
83
70
|
data = STDIN.sysread(4 * 1024)
|
@@ -92,6 +79,7 @@ temp.open
|
|
92
79
|
# upload temp file
|
93
80
|
begin
|
94
81
|
@s3.interface.put(bucket, key, temp, @headers)
|
82
|
+
STDERR.puts "s3://#{bucket}/#{key} => #{S3CP.format_filesize(temp.size)} "
|
95
83
|
ensure
|
96
84
|
# cleanup
|
97
85
|
temp.close
|
data/lib/s3cp/utils.rb
CHANGED
@@ -45,6 +45,19 @@ module S3CP
|
|
45
45
|
[bucket, key]
|
46
46
|
end
|
47
47
|
|
48
|
+
def headers_array_to_hash(header_array)
|
49
|
+
headers = {}
|
50
|
+
header_array.each do |header|
|
51
|
+
header_parts = header.split(": ", 2)
|
52
|
+
if header_parts.size == 2
|
53
|
+
headers[header_parts[0].downcase] = header_parts[1] # RightAWS gem expect lowercase header names :(
|
54
|
+
else
|
55
|
+
fail("Invalid header value; expected single colon delimiter; e.g. Header: Value")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
headers
|
59
|
+
end
|
60
|
+
|
48
61
|
# Round a number at some `decimals` level of precision.
|
49
62
|
def round(n, decimals = 0)
|
50
63
|
(n * (10.0 ** decimals)).round * (10.0 ** (-decimals))
|
data/lib/s3cp/version.rb
CHANGED
metadata
CHANGED