File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ def send_upload_command(client)
141141 logger . debug { sprintf ( 'Sending upload command to %s' , @upload_url ) }
142142
143143 remaining_content_size = upload_io . size - @offset
144- current_chunk_size = remaining_content_size < @upload_chunk_size ? remaining_content_size : @upload_chunk_size
144+ current_chunk_size = get_current_chunk_size remaining_content_size
145145
146146 request_header = header . dup
147147 request_header [ CONTENT_RANGE_HEADER ] = get_content_range_header current_chunk_size
@@ -181,6 +181,15 @@ def streamable?(upload_source)
181181 upload_source . is_a? ( IO ) || upload_source . is_a? ( StringIO ) || upload_source . is_a? ( Tempfile )
182182 end
183183
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+
184193 def get_content_range_header current_chunk_size
185194 if upload_io . size == 0
186195 numerator = "*"
Original file line number Diff line number Diff line change 129129 end
130130 end
131131
132+ context ( 'with chunking disabled' ) do
133+ let ( :file ) { StringIO . new ( "Hello world" ) }
134+ include_examples 'should upload'
135+
136+ it 'should upload content in one request' do
137+ command . options . upload_chunk_size = 0
138+ command . execute ( client )
139+ expect ( a_request ( :put , 'https://www.googleapis.com/zoo/animals' )
140+ . with ( body : "Hello world" ) ) . to have_been_made
141+ end
142+ end
143+
132144 context 'with retriable error on start' do
133145 let ( :file ) { StringIO . new "Hello world" }
134146 before ( :example ) do
You can’t perform that action at this time.
0 commit comments