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