Google\Cloud\Upload\ResumableUploader::resume PHP Method

resume() public method

Resumes a download using the provided URI.
public resume ( string $resumeUri ) : array
$resumeUri string
return array
    public function resume($resumeUri)
    {
        if (!$this->data->isSeekable()) {
            throw new GoogleException('Cannot resume upload on a stream which cannot be seeked.');
        }
        $this->resumeUri = $resumeUri;
        $response = $this->getStatusResponse();
        if ($response->getBody()->getSize() > 0) {
            return json_decode($response->getBody(), true);
        }
        $this->rangeStart = $this->getRangeStart($response->getHeaderLine('Range'));
        return $this->upload();
    }

Usage Example

 /**
  * @expectedException Google\Cloud\Exception\GoogleException
  */
 public function testThrowsExceptionWhenResumingNonSeekableStream()
 {
     $stream = $this->prophesize('Psr\\Http\\Message\\StreamInterface');
     $stream->isSeekable()->willReturn(false);
     $stream->getMetadata('uri')->willReturn('blah');
     $uploader = new ResumableUploader($this->requestWrapper->reveal(), $stream->reveal(), 'http://www.example.com');
     $uploader->resume('http://some-resume-uri.example.com');
 }