google-apis-core 0.9.4 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/google/apis/core/storage_upload.rb +17 -3
- data/lib/google/apis/core/version.rb +1 -1
- data/lib/google/apis/options.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 330bf699ecc5c12098da65f7b89e276d3670fb6cca1270960820d5c369be806d
|
4
|
+
data.tar.gz: 843c6278d958141541fb12176f3eec28d0a0c6e09fbefd2d27a717ef59859bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ec08bdf72e469182007ba51c0175c45705d5bc45d651bafe14635f31f4ccbba4d9ba5ff10774e1170144d3196b88ad493d324b7450c009685ec80770e43f28
|
7
|
+
data.tar.gz: a2f3ceec0e14b0d6af9bfcbf47627afb30f39764713f6e8d187413e54dab46446416911257b6f40a2baf1fa91471ef30f7e14dfe0b2b111057bb736bc7e00119
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 0.10.0 (2023-01-26)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Allow chunk size zero for storage resumable upload ([#13283](https://github.com/googleapis/google-api-ruby-client/issues/13283))
|
8
|
+
* Make chunk size configurable ([#13216](https://github.com/googleapis/google-api-ruby-client/issues/13216))
|
9
|
+
|
10
|
+
### 0.9.5 (2023-01-12)
|
11
|
+
|
12
|
+
#### Bug Fixes
|
13
|
+
|
14
|
+
* Improve upload performance for Cloud Storage ([#13213](https://github.com/googleapis/google-api-ruby-client/issues/13213))
|
15
|
+
|
3
16
|
### 0.9.4 (2023-01-07)
|
4
17
|
|
5
18
|
#### Bug Fixes
|
@@ -15,6 +15,7 @@
|
|
15
15
|
require 'google/apis/core/http_command'
|
16
16
|
require 'google/apis/core/api_command'
|
17
17
|
require 'google/apis/errors'
|
18
|
+
require 'stringio'
|
18
19
|
require 'tempfile'
|
19
20
|
require 'mini_mime'
|
20
21
|
|
@@ -31,7 +32,6 @@ module Google
|
|
31
32
|
CONTENT_RANGE_HEADER = "Content-Range"
|
32
33
|
RESUMABLE = "resumable"
|
33
34
|
OK_STATUS = 200
|
34
|
-
CHUNK_SIZE = 8 * 1024 * 1024 # 8 MB
|
35
35
|
|
36
36
|
# File name or IO containing the content to upload
|
37
37
|
# @return [String, File, #read]
|
@@ -45,6 +45,10 @@ module Google
|
|
45
45
|
# @return [Google::Apis::Core::UploadIO]
|
46
46
|
attr_accessor :upload_io
|
47
47
|
|
48
|
+
# Upload chunk size
|
49
|
+
# @return [Integer]
|
50
|
+
attr_accessor :upload_chunk_size
|
51
|
+
|
48
52
|
# Ensure the content is readable and wrapped in an IO instance.
|
49
53
|
#
|
50
54
|
# @return [void]
|
@@ -91,6 +95,7 @@ module Google
|
|
91
95
|
def execute(client)
|
92
96
|
prepare!
|
93
97
|
opencensus_begin_span
|
98
|
+
@upload_chunk_size = options.upload_chunk_size
|
94
99
|
|
95
100
|
do_retry :initiate_resumable_upload, client
|
96
101
|
while @upload_incomplete
|
@@ -136,12 +141,12 @@ module Google
|
|
136
141
|
logger.debug { sprintf('Sending upload command to %s', @upload_url) }
|
137
142
|
|
138
143
|
remaining_content_size = upload_io.size - @offset
|
139
|
-
current_chunk_size =
|
144
|
+
current_chunk_size = get_current_chunk_size remaining_content_size
|
140
145
|
|
141
146
|
request_header = header.dup
|
142
147
|
request_header[CONTENT_RANGE_HEADER] = get_content_range_header current_chunk_size
|
143
148
|
request_header[CONTENT_LENGTH_HEADER] = current_chunk_size
|
144
|
-
chunk_body = upload_io.read(current_chunk_size)
|
149
|
+
chunk_body = StringIO.new(upload_io.read(current_chunk_size))
|
145
150
|
|
146
151
|
response = client.put(@upload_url, body: chunk_body, header: request_header, follow_redirect: true)
|
147
152
|
|
@@ -176,6 +181,15 @@ module Google
|
|
176
181
|
upload_source.is_a?(IO) || upload_source.is_a?(StringIO) || upload_source.is_a?(Tempfile)
|
177
182
|
end
|
178
183
|
|
184
|
+
def get_current_chunk_size remaining_content_size
|
185
|
+
# Disable chunking if the chunk size is set to zero.
|
186
|
+
if @upload_chunk_size == 0
|
187
|
+
remaining_content_size
|
188
|
+
else
|
189
|
+
remaining_content_size < @upload_chunk_size ? remaining_content_size : @upload_chunk_size
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
179
193
|
def get_content_range_header current_chunk_size
|
180
194
|
if upload_io.size == 0
|
181
195
|
numerator = "*"
|
data/lib/google/apis/options.rb
CHANGED
@@ -40,7 +40,8 @@ module Google
|
|
40
40
|
:use_opencensus,
|
41
41
|
:quota_project,
|
42
42
|
:query,
|
43
|
-
:add_invocation_id_header
|
43
|
+
:add_invocation_id_header,
|
44
|
+
:upload_chunk_size)
|
44
45
|
|
45
46
|
# General client options
|
46
47
|
class ClientOptions
|
@@ -98,6 +99,8 @@ module Google
|
|
98
99
|
# @return [Hash<String,String>] Additional HTTP URL query parameters to include in requests.
|
99
100
|
# @!attribute [rw] add_invocation_id_header
|
100
101
|
# @return [Boolean] True if the header gccl-invocation-id need to be set
|
102
|
+
# @!attribute [rw] upload_chunk_size
|
103
|
+
# @return [Integer] The chunk size of storage upload. The default value is 100 MB.
|
101
104
|
|
102
105
|
# Get the default options
|
103
106
|
# @return [Google::Apis::RequestOptions]
|
@@ -133,5 +136,6 @@ module Google
|
|
133
136
|
RequestOptions.default.use_opencensus = true
|
134
137
|
RequestOptions.default.quota_project = nil
|
135
138
|
RequestOptions.default.add_invocation_id_header = false
|
139
|
+
RequestOptions.default.upload_chunk_size = 100 * 1024 * 1024 # 100 MB
|
136
140
|
end
|
137
141
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-apis-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: representable
|
@@ -186,7 +186,7 @@ licenses:
|
|
186
186
|
metadata:
|
187
187
|
bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
|
188
188
|
changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core/CHANGELOG.md
|
189
|
-
documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.
|
189
|
+
documentation_uri: https://googleapis.dev/ruby/google-apis-core/v0.10.0
|
190
190
|
source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-core
|
191
191
|
post_install_message:
|
192
192
|
rdoc_options: []
|