|
@@ -1,6 +1,6 @@
|
|
#!/usr/bin/env ruby
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
-# Generated on: 15-09-2013 at 01:09
|
|
|
|
|
|
+# Generated on: 20-09-2013 at 12:38
|
|
|
|
|
|
require 'time'
|
|
require 'time'
|
|
require 'net/http'
|
|
require 'net/http'
|
|
@@ -10,7 +10,7 @@ require 'digest/sha1'
|
|
require 'fileutils'
|
|
require 'fileutils'
|
|
require 'openssl'
|
|
require 'openssl'
|
|
require 'base64'
|
|
require 'base64'
|
|
-
|
|
|
|
|
|
+require 'cgi'
|
|
class Presss
|
|
class Presss
|
|
# Computes the Authorization header for a AWS request based on a message,
|
|
# Computes the Authorization header for a AWS request based on a message,
|
|
# the access key ID and secret access key.
|
|
# the access key ID and secret access key.
|
|
@@ -102,13 +102,13 @@ class Presss
|
|
canonical_path = canonicalized_resource(path)
|
|
canonical_path = canonicalized_resource(path)
|
|
signature = [ verb.to_s.upcase, nil, nil, expires, [ headers, canonical_path ].flatten.compact ].flatten.join("\n")
|
|
signature = [ verb.to_s.upcase, nil, nil, expires, [ headers, canonical_path ].flatten.compact ].flatten.join("\n")
|
|
signed = authorization.sign(signature)
|
|
signed = authorization.sign(signature)
|
|
- "#{url_prefix}#{path}?Signature=#{signed}&Expires=#{expires}&AWSAccessKeyId=#{authorization.access_key_id}"
|
|
|
|
|
|
+ "#{url_prefix}#{path}?Signature=#{CGI.escape(signed)}&Expires=#{expires}&AWSAccessKeyId=#{CGI.escape(authorization.access_key_id)}"
|
|
end
|
|
end
|
|
|
|
|
|
def download(path, destination)
|
|
def download(path, destination)
|
|
url = signed_url(:get, Time.now.to_i + 600, nil, path)
|
|
url = signed_url(:get, Time.now.to_i + 600, nil, path)
|
|
Presss.log "signed_url=#{url}"
|
|
Presss.log "signed_url=#{url}"
|
|
- system 'curl', '-f', '-o', destination, url
|
|
|
|
|
|
+ system 'curl', '-f', '-S', '-o', destination, url
|
|
$?.success?
|
|
$?.success?
|
|
end
|
|
end
|
|
|
|
|
|
@@ -118,7 +118,7 @@ class Presss
|
|
header = 'x-amz-storage-class:REDUCED_REDUNDANCY'
|
|
header = 'x-amz-storage-class:REDUCED_REDUNDANCY'
|
|
url = signed_url(:put, Time.now.to_i + 600, header, path)
|
|
url = signed_url(:put, Time.now.to_i + 600, header, path)
|
|
Presss.log "signed_url=#{url}"
|
|
Presss.log "signed_url=#{url}"
|
|
- system 'curl', '-f', '-H', header, '-T', file, url
|
|
|
|
|
|
+ system 'curl', '-f', '-S', '-H', header, '-T', file, url
|
|
$?.success?
|
|
$?.success?
|
|
end
|
|
end
|
|
end
|
|
end
|