google-cloud-storage 1.52.0 → 1.54.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/google/cloud/storage/bucket/cors.rb +2 -2
- data/lib/google/cloud/storage/bucket.rb +4 -4
- data/lib/google/cloud/storage/file/signer_v2.rb +3 -3
- data/lib/google/cloud/storage/file/signer_v4.rb +4 -4
- data/lib/google/cloud/storage/file.rb +48 -6
- data/lib/google/cloud/storage/service.rb +0 -4
- data/lib/google/cloud/storage/version.rb +1 -1
- data/lib/google/cloud/storage.rb +4 -4
- data/lib/google-cloud-storage.rb +8 -10
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fa1effce117003750f759eba79de92380616365652f2a19ba49b1986c75634
|
4
|
+
data.tar.gz: 9729e6dc51f15a9a5e2e0370771f980908f9d6284973503c9c4d4c1e561b8d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec9022c921c0714ebf7f47131c745c113bb0480a34a376ca10055ccdee024821a518d1a87f742486118d7fb3e570beaeef5746f12676d5790e6ae697439dabd9
|
7
|
+
data.tar.gz: d5e57fd75d565a8328cf79ce42374883e4da7f875c7fd9571e928f9648c05578bee5743d68465819f3e5d488469d277749aecebd44810198fd1a1ca0cac6f3c3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.54.0 (2024-12-11)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Updated required Ruby version to 3.0 or later ([#27599](https://github.com/googleapis/google-cloud-ruby/issues/27599))
|
8
|
+
|
9
|
+
### 1.53.0 (2024-12-04)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* add integration test for universe domain ([#27384](https://github.com/googleapis/google-cloud-ruby/issues/27384))
|
14
|
+
* fetch file and bucket details from url ([#27322](https://github.com/googleapis/google-cloud-ruby/issues/27322))
|
15
|
+
|
3
16
|
### 1.52.0 (2024-05-31)
|
4
17
|
|
5
18
|
#### Features
|
@@ -182,7 +182,7 @@ module Google
|
|
182
182
|
@origin = Array(origin)
|
183
183
|
@methods = Array(methods)
|
184
184
|
@headers = Array(headers)
|
185
|
-
@max_age =
|
185
|
+
@max_age = max_age || 1800
|
186
186
|
end
|
187
187
|
|
188
188
|
# @private
|
@@ -195,7 +195,7 @@ module Google
|
|
195
195
|
|
196
196
|
# @private
|
197
197
|
def self.from_gapi gapi
|
198
|
-
new gapi.origin.dup, gapi.http_method.dup,
|
198
|
+
new gapi.origin.dup, gapi.http_method.dup,
|
199
199
|
headers: gapi.response_header.dup,
|
200
200
|
max_age: gapi.max_age_seconds
|
201
201
|
end
|
@@ -3187,9 +3187,9 @@ module Google
|
|
3187
3187
|
attributes.flatten!
|
3188
3188
|
return if attributes.empty?
|
3189
3189
|
ensure_service!
|
3190
|
-
patch_args =
|
3190
|
+
patch_args = attributes.to_h do |attr|
|
3191
3191
|
[attr, @gapi.send(attr)]
|
3192
|
-
end
|
3192
|
+
end
|
3193
3193
|
patch_gapi = API::Bucket.new(**patch_args)
|
3194
3194
|
@gapi = service.patch_bucket name,
|
3195
3195
|
patch_gapi,
|
@@ -3207,9 +3207,9 @@ module Google
|
|
3207
3207
|
attributes.flatten!
|
3208
3208
|
return if attributes.empty?
|
3209
3209
|
ensure_service!
|
3210
|
-
update_args =
|
3210
|
+
update_args = attributes.to_h do |attr|
|
3211
3211
|
[attr, @gapi.send(attr)]
|
3212
|
-
end
|
3212
|
+
end
|
3213
3213
|
update_gapi = API::Bucket.new(**update_args)
|
3214
3214
|
@gapi = service.update_bucket name,
|
3215
3215
|
update_gapi,
|
@@ -92,7 +92,7 @@ module Google
|
|
92
92
|
|
93
93
|
def error_msg attr_name
|
94
94
|
"Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
|
95
|
-
|
95
|
+
"see https://cloud.google.com/iam/docs/service-accounts"
|
96
96
|
end
|
97
97
|
|
98
98
|
def post_object options
|
@@ -145,8 +145,8 @@ module Google
|
|
145
145
|
|
146
146
|
def generate_signed_url issuer, signed_string, expires, query
|
147
147
|
url = "#{ext_url}?GoogleAccessId=#{url_escape issuer}" \
|
148
|
-
|
149
|
-
|
148
|
+
"&Expires=#{expires}" \
|
149
|
+
"&Signature=#{url_escape signed_string}"
|
150
150
|
|
151
151
|
query&.each do |name, value|
|
152
152
|
url << "&#{url_escape name}=#{url_escape value}"
|
@@ -131,7 +131,7 @@ module Google
|
|
131
131
|
# methods below are public visibility only for unit testing
|
132
132
|
# rubocop:disable Style/StringLiterals
|
133
133
|
def escape_characters str
|
134
|
-
str.
|
134
|
+
str.chars.map do |s|
|
135
135
|
if s.ascii_only?
|
136
136
|
case s
|
137
137
|
when "\\"
|
@@ -207,7 +207,7 @@ module Google
|
|
207
207
|
|
208
208
|
def error_msg attr_name
|
209
209
|
"Service account credentials '#{attr_name}' is missing. To generate service account credentials " \
|
210
|
-
|
210
|
+
"see https://cloud.google.com/iam/docs/service-accounts"
|
211
211
|
end
|
212
212
|
|
213
213
|
def service_account_signer signer
|
@@ -243,7 +243,7 @@ module Google
|
|
243
243
|
headers_arr = canonical_headers.map do |k, v|
|
244
244
|
[k.downcase, v.strip.gsub(/[^\S\t]+/, " ").gsub(/\t+/, " ")]
|
245
245
|
end
|
246
|
-
canonical_headers =
|
246
|
+
canonical_headers = headers_arr.to_h
|
247
247
|
canonical_headers["host"] = host_name virtual_hosted_style, bucket_bound_hostname
|
248
248
|
|
249
249
|
canonical_headers = canonical_headers.sort_by(&:first).to_h
|
@@ -295,7 +295,7 @@ module Google
|
|
295
295
|
##
|
296
296
|
# The external path to the bucket, with trailing slash.
|
297
297
|
def bucket_path path_style
|
298
|
-
|
298
|
+
"/#{@bucket_name}/" if path_style
|
299
299
|
end
|
300
300
|
|
301
301
|
##
|
@@ -2072,15 +2072,59 @@ module Google
|
|
2072
2072
|
def self.gapi_from_attrs gapi, attributes
|
2073
2073
|
attributes.flatten!
|
2074
2074
|
return nil if attributes.empty?
|
2075
|
-
attr_params =
|
2076
|
-
|
2077
|
-
|
2075
|
+
attr_params = attributes.to_h do |attr|
|
2076
|
+
[attr, gapi.send(attr)]
|
2077
|
+
end
|
2078
2078
|
# Sending nil metadata results in an Apiary runtime error:
|
2079
2079
|
# NoMethodError: undefined method `each' for nil:NilClass
|
2080
2080
|
attr_params.reject! { |k, v| k == :metadata && v.nil? }
|
2081
2081
|
Google::Apis::StorageV1::Object.new(**attr_params)
|
2082
2082
|
end
|
2083
2083
|
|
2084
|
+
##
|
2085
|
+
# from_gs_url is a method to fetch bucket details and file details from a gs url
|
2086
|
+
#
|
2087
|
+
# @return [Hash(String => String)]
|
2088
|
+
#
|
2089
|
+
# @example Fetch bucket_name and file_Path from gs url:
|
2090
|
+
# require "google/cloud/storage"
|
2091
|
+
# gs_url= "gs://my-todo-app/avatars/heidi.jpeg"
|
2092
|
+
# file=Google::Cloud::Storage::File
|
2093
|
+
# file.from_gs_url(gs_url)
|
2094
|
+
# =>
|
2095
|
+
# {"bucket_name"=>"my-todo-app", "file_path"=>"avatars/heidi.jpeg"}
|
2096
|
+
#
|
2097
|
+
# @example Fetch bucket_name , file_Path and other query params from gs url:
|
2098
|
+
# require "google/cloud/storage"
|
2099
|
+
# gs_url= "gs://my-todo-app/test_sub_folder/heidi.jpeg?params1=test1¶ms2=test2"
|
2100
|
+
# file=Google::Cloud::Storage::File
|
2101
|
+
# file.from_gs_url(gs_url)
|
2102
|
+
# =>{
|
2103
|
+
# "bucket_name"=>"my-todo-app",
|
2104
|
+
# "file_path"=>"test_sub_folder/heidi.jpeg",
|
2105
|
+
# "options" => {
|
2106
|
+
# "params1"=>"test1",
|
2107
|
+
# "params2"=>"test2"
|
2108
|
+
# }
|
2109
|
+
# }
|
2110
|
+
|
2111
|
+
def self.from_gs_url gs_url
|
2112
|
+
prefix = "gs://".freeze
|
2113
|
+
raise ArgumentError, "Invalid GCS URL" unless gs_url.start_with? prefix
|
2114
|
+
# seprating params from input url
|
2115
|
+
path, query = gs_url.sub(prefix, "").split("?", 2)
|
2116
|
+
# parsing the url
|
2117
|
+
bucket_name, file_path = path.split "/", 2
|
2118
|
+
query_params = URI.decode_www_form(query).to_h if query
|
2119
|
+
url_items = {
|
2120
|
+
"bucket_name" => bucket_name,
|
2121
|
+
"file_path" => file_path
|
2122
|
+
}
|
2123
|
+
# adding url params to output hash
|
2124
|
+
url_items.merge! "options" => query_params if query
|
2125
|
+
url_items
|
2126
|
+
end
|
2127
|
+
|
2084
2128
|
protected
|
2085
2129
|
|
2086
2130
|
##
|
@@ -2196,10 +2240,8 @@ module Google
|
|
2196
2240
|
[dest_bucket, dest_path]
|
2197
2241
|
end
|
2198
2242
|
|
2199
|
-
# rubocop:disable Style/MultipleComparison
|
2200
|
-
|
2201
2243
|
def verify_file! file, verify = :md5
|
2202
|
-
verify_md5 = verify == :md5
|
2244
|
+
verify_md5 = verify == :md5 || verify == :all
|
2203
2245
|
verify_crc32c = verify == :crc32c || verify == :all
|
2204
2246
|
Verifier.verify_md5! self, file if verify_md5 && md5
|
2205
2247
|
Verifier.verify_crc32c! self, file if verify_crc32c && crc32c
|
@@ -543,7 +543,6 @@ module Google
|
|
543
543
|
if_metageneration_match: nil,
|
544
544
|
user_project: nil,
|
545
545
|
options: {}
|
546
|
-
|
547
546
|
source_objects = compose_file_source_objects source_files, if_source_generation_match
|
548
547
|
compose_req = Google::Apis::StorageV1::ComposeRequest.new source_objects: source_objects,
|
549
548
|
destination: destination_gapi
|
@@ -638,7 +637,6 @@ module Google
|
|
638
637
|
if_metageneration_not_match: nil,
|
639
638
|
user_project: nil,
|
640
639
|
options: {}
|
641
|
-
|
642
640
|
if options[:retries].nil?
|
643
641
|
is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
|
644
642
|
options = is_idempotent ? {} : { retries: 0 }
|
@@ -670,7 +668,6 @@ module Google
|
|
670
668
|
user_project: nil,
|
671
669
|
fields: nil,
|
672
670
|
options: {}
|
673
|
-
|
674
671
|
if options[:retries].nil?
|
675
672
|
is_idempotent = retry? generation: generation, if_generation_match: if_generation_match
|
676
673
|
options = is_idempotent ? {} : { retries: 0 }
|
@@ -738,7 +735,6 @@ module Google
|
|
738
735
|
# Returns Google::Apis::StorageV1::HmacKey.
|
739
736
|
def create_hmac_key service_account_email, project_id: nil,
|
740
737
|
user_project: nil, options: {}
|
741
|
-
|
742
738
|
if options[:retries].nil?
|
743
739
|
options = options.merge({ retries: 0 })
|
744
740
|
end
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -98,11 +98,11 @@ module Google
|
|
98
98
|
scope ||= configure.scope
|
99
99
|
retries ||= configure.retries
|
100
100
|
timeout ||= configure.timeout
|
101
|
-
open_timeout ||=
|
102
|
-
read_timeout ||=
|
103
|
-
send_timeout ||=
|
101
|
+
open_timeout ||= configure.open_timeout || timeout
|
102
|
+
read_timeout ||= configure.read_timeout || timeout
|
103
|
+
send_timeout ||= configure.send_timeout || timeout
|
104
104
|
endpoint ||= configure.endpoint
|
105
|
-
credentials ||=
|
105
|
+
credentials ||= keyfile || default_credentials(scope: scope)
|
106
106
|
max_elapsed_time ||= configure.max_elapsed_time
|
107
107
|
base_interval ||= configure.base_interval
|
108
108
|
max_interval ||= configure.max_interval
|
data/lib/google-cloud-storage.rb
CHANGED
@@ -79,11 +79,11 @@ module Google
|
|
79
79
|
def storage scope: nil, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil,
|
80
80
|
max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil
|
81
81
|
Google::Cloud.storage @project, @keyfile, scope: scope,
|
82
|
-
retries:
|
83
|
-
timeout:
|
84
|
-
open_timeout:
|
85
|
-
read_timeout:
|
86
|
-
send_timeout:
|
82
|
+
retries: retries || @retries,
|
83
|
+
timeout: timeout || @timeout,
|
84
|
+
open_timeout: open_timeout || timeout,
|
85
|
+
read_timeout: read_timeout || timeout,
|
86
|
+
send_timeout: send_timeout || timeout,
|
87
87
|
max_elapsed_time: max_elapsed_time,
|
88
88
|
base_interval: base_interval,
|
89
89
|
max_interval: max_interval,
|
@@ -149,9 +149,9 @@ module Google
|
|
149
149
|
scope: scope,
|
150
150
|
retries: retries,
|
151
151
|
timeout: timeout,
|
152
|
-
open_timeout:
|
153
|
-
read_timeout:
|
154
|
-
send_timeout:
|
152
|
+
open_timeout: open_timeout || timeout,
|
153
|
+
read_timeout: read_timeout || timeout,
|
154
|
+
send_timeout: send_timeout || timeout,
|
155
155
|
max_elapsed_time: max_elapsed_time,
|
156
156
|
base_interval: base_interval,
|
157
157
|
max_interval: max_interval,
|
@@ -162,7 +162,6 @@ module Google
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Set the default storage configuration
|
165
|
-
# rubocop:disable Metrics/BlockLength
|
166
165
|
Google::Cloud.configure.add_config! :storage do |config|
|
167
166
|
default_project = Google::Cloud::Config.deferred do
|
168
167
|
ENV["STORAGE_PROJECT"]
|
@@ -195,4 +194,3 @@ Google::Cloud.configure.add_config! :storage do |config|
|
|
195
194
|
config.add_field! :endpoint, nil, match: String, allow_nil: true
|
196
195
|
config.add_field! :universe_domain, nil, match: String, allow_nil: true
|
197
196
|
end
|
198
|
-
# rubocop:enable Metrics/BlockLength
|
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.
|
4
|
+
version: 1.54.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: 2024-
|
12
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.
|
132
|
+
version: 1.30.0
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
139
|
+
version: 1.30.0
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: minitest
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,14 +333,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
333
333
|
requirements:
|
334
334
|
- - ">="
|
335
335
|
- !ruby/object:Gem::Version
|
336
|
-
version:
|
336
|
+
version: 3.0.0
|
337
337
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
338
338
|
requirements:
|
339
339
|
- - ">="
|
340
340
|
- !ruby/object:Gem::Version
|
341
341
|
version: '0'
|
342
342
|
requirements: []
|
343
|
-
rubygems_version: 3.5.
|
343
|
+
rubygems_version: 3.5.23
|
344
344
|
signing_key:
|
345
345
|
specification_version: 4
|
346
346
|
summary: API Client library for Google Cloud Storage
|