google-cloud-storage 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef777ddfd6e259d9f116f3a5996d058d852b7d49
4
- data.tar.gz: 9e197669439fe3b3dc9a7bc2a6cbdb6ce9a76bc0
3
+ metadata.gz: 474743d603eb149e305fbbbaf7db863b04806cc0
4
+ data.tar.gz: f8eb5c36d9816604516c4c0d91c5350ba5152c76
5
5
  SHA512:
6
- metadata.gz: 44a7f28a56c19e8b9014891eca1a559e8481b25ea2a0f0ed2ea244793f883395f26ddaf1cdc9d996469ed991f478d969d11151bdd2543e09f2b51d667248c400
7
- data.tar.gz: e8db734cf23c2a8fc846baaee9779b9212abd3f5150eeb2e9d5d4ef3094c5803e0d608624d1e228542e6bf61cb0f53cf158b68bed267c80ca4dc5b2124dc226f
6
+ metadata.gz: e75929f212d3cea1b8b7064136ff2a6228571358225e1980ba5f46d982a31dc212d50cda1d59d117356c8429388b89d40502352f7020c7578a40e5361dc4ba82
7
+ data.tar.gz: ebd0b51233c64e48728850b2eb0a0e5ad4699486e0bc8a12d7be442b34092e7c73419051c857dabd4a23b6693da1a0d3bf9e2e3287e61df2a5bc9d0a523d16d4
@@ -733,6 +733,14 @@ module Google
733
733
  # Private Key.
734
734
  # @param [OpenSSL::PKey::RSA, String] private_key Service Account's
735
735
  # Private Key.
736
+ # @param [Hash] query Query string parameters to include in the signed
737
+ # URL. The given parameters are not verified by the signature.
738
+ #
739
+ # Parameters such as `response-content-disposition` and
740
+ # `response-content-type` can alter the behavior of the response when
741
+ # using the URL, but only when the file resource is missing the
742
+ # corresponding values. (These values can be permanently set using
743
+ # {File#content_disposition=} and {File#content_type=}.)
736
744
  #
737
745
  # @example
738
746
  # require "google/cloud/storage"
@@ -778,14 +786,16 @@ module Google
778
786
  #
779
787
  def signed_url path, method: nil, expires: nil, content_type: nil,
780
788
  content_md5: nil, headers: nil, issuer: nil,
781
- client_email: nil, signing_key: nil, private_key: nil
789
+ client_email: nil, signing_key: nil, private_key: nil,
790
+ query: nil
782
791
  ensure_service!
783
- options = { method: method, expires: expires, headers: headers,
784
- content_type: content_type, content_md5: content_md5,
785
- issuer: issuer, client_email: client_email,
786
- signing_key: signing_key, private_key: private_key }
787
792
  signer = File::Signer.from_bucket self, path
788
- signer.signed_url options
793
+ signer.signed_url method: method, expires: expires, headers: headers,
794
+ content_type: content_type,
795
+ content_md5: content_md5, issuer: issuer,
796
+ client_email: client_email,
797
+ signing_key: signing_key, private_key: private_key,
798
+ query: query
789
799
  end
790
800
 
791
801
  ##
@@ -731,6 +731,14 @@ module Google
731
731
  # Private Key.
732
732
  # @param [OpenSSL::PKey::RSA, String] private_key Service Account's
733
733
  # Private Key.
734
+ # @param [Hash] query Query string parameters to include in the signed
735
+ # URL. The given parameters are not verified by the signature.
736
+ #
737
+ # Parameters such as `response-content-disposition` and
738
+ # `response-content-type` can alter the behavior of the response when
739
+ # using the URL, but only when the file resource is missing the
740
+ # corresponding values. (These values can be permanently set using
741
+ # {#content_disposition=} and {#content_type=}.)
734
742
  #
735
743
  # @example
736
744
  # require "google/cloud/storage"
@@ -778,14 +786,16 @@ module Google
778
786
  #
779
787
  def signed_url method: nil, expires: nil, content_type: nil,
780
788
  content_md5: nil, headers: nil, issuer: nil,
781
- client_email: nil, signing_key: nil, private_key: nil
789
+ client_email: nil, signing_key: nil, private_key: nil,
790
+ query: nil
782
791
  ensure_service!
783
792
  signer = File::Signer.from_file self
784
793
  signer.signed_url method: method, expires: expires, headers: headers,
785
794
  content_type: content_type,
786
795
  content_md5: content_md5,
787
796
  issuer: issuer, client_email: client_email,
788
- signing_key: signing_key, private_key: private_key
797
+ signing_key: signing_key, private_key: private_key,
798
+ query: query
789
799
  end
790
800
 
791
801
  ##
@@ -109,7 +109,7 @@ module Google
109
109
  fail SignedUrlUnavailable unless i && s
110
110
 
111
111
  sig = generate_signature s, signature_str(options)
112
- generate_signed_url i, sig, options[:expires]
112
+ generate_signed_url i, sig, options[:expires], options[:query]
113
113
  end
114
114
 
115
115
  def generate_signature signing_key, secret
@@ -120,10 +120,18 @@ module Google
120
120
  Base64.strict_encode64(signature).delete("\n")
121
121
  end
122
122
 
123
- def generate_signed_url issuer, signed_string, expires
124
- "#{ext_url}?GoogleAccessId=#{CGI.escape issuer}" \
123
+ def generate_signed_url issuer, signed_string, expires, query
124
+ url = "#{ext_url}?GoogleAccessId=#{CGI.escape issuer}" \
125
125
  "&Expires=#{expires}" \
126
126
  "&Signature=#{CGI.escape signed_string}"
127
+
128
+ if query
129
+ query.each do |name, value|
130
+ url << "&#{CGI.escape name}=#{CGI.escape value}"
131
+ end
132
+ end
133
+
134
+ url
127
135
  end
128
136
 
129
137
  def format_extension_headers headers
@@ -375,6 +375,14 @@ module Google
375
375
  # Private Key.
376
376
  # @param [OpenSSL::PKey::RSA, String] private_key Service Account's
377
377
  # Private Key.
378
+ # @param [Hash] query Query string parameters to include in the signed
379
+ # URL. The given parameters are not verified by the signature.
380
+ #
381
+ # Parameters such as `response-content-disposition` and
382
+ # `response-content-type` can alter the behavior of the response when
383
+ # using the URL, but only when the file resource is missing the
384
+ # corresponding values. (These values can be permanently set using
385
+ # {File#content_disposition=} and {File#content_type=}.)
378
386
  #
379
387
  # @example
380
388
  # require "google/cloud/storage"
@@ -426,13 +434,14 @@ module Google
426
434
  def signed_url bucket, path, method: nil, expires: nil,
427
435
  content_type: nil, content_md5: nil, headers: nil,
428
436
  issuer: nil, client_email: nil, signing_key: nil,
429
- private_key: nil
437
+ private_key: nil, query: nil
430
438
  signer = File::Signer.new bucket, path, service
431
439
  signer.signed_url method: method, expires: expires, headers: headers,
432
440
  content_type: content_type,
433
441
  content_md5: content_md5,
434
442
  issuer: issuer, client_email: client_email,
435
- signing_key: signing_key, private_key: private_key
443
+ signing_key: signing_key, private_key: private_key,
444
+ query: query
436
445
  end
437
446
 
438
447
  protected
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.2.0"
19
+ VERSION = "1.3.0"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-27 00:00:00.000000000 Z
12
+ date: 2017-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core