getResumeUri(); if ($writeSize) { $rangeEnd = $this->rangeStart + $writeSize - 1; $data = $this->data->read($writeSize); } else { $rangeEnd = '*'; $data = $this->data->getContents(); $writeSize = strlen($data); } // do the streaming write $headers = [ 'Content-Length' => $writeSize, 'Content-Type' => $this->contentType, 'Content-Range' => "bytes {$this->rangeStart}-$rangeEnd/*" ]; $request = new Request( 'PUT', $resumeUri, $headers, $data ); try { $response = $this->requestWrapper->send($request, $this->requestOptions); } catch (ServiceException $ex) { throw new GoogleException( "Upload failed. Please use this URI to resume your upload: $resumeUri", $ex->getCode(), $ex ); } // reset the buffer with the remaining contents $this->rangeStart += $writeSize; return json_decode($response->getBody(), true); } /** * Currently only the MultiPartUploader supports async. * * Any calls to this will throw a generic Google Exception. * * @return PromiseInterface * @throws GoogleException * @experimental The experimental flag means that while we believe this method * or class is ready for use, it may change before release in backwards- * incompatible ways. Please use with caution, and test thoroughly when * upgrading. */ public function uploadAsync() { throw new GoogleException('Currently only the MultiPartUploader supports async.'); } }