Google\Cloud\Storage\Bucket::getResumableUploader PHP Method

getResumableUploader() public method

Example: $uploader = $bucket->getResumableUploader( fopen(__DIR__ . '/image.jpg', 'r') ); try { $object = $uploader->upload(); } catch (GoogleException $ex) { $resumeUri = $uploader->getResumeUri(); $object = $uploader->resume($resumeUri); }
See also: https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#resumable Learn more about resumable uploads.
See also: https://cloud.google.com/storage/docs/json_api/v1/objects/insert Objects insert API documentation.
public getResumableUploader ( string | resource | Psr\Http\Message\StreamInterface $data, array $options = [] ) : ResumableUploader
$data string | resource | Psr\Http\Message\StreamInterface The data to be uploaded.
$options array [optional] { Configuration options. @type string $name The name of the destination. @type bool $validate Indicates whether or not validation will be applied using md5 hashing functionality. If true and the calculated hash does not match that of the upstream server the upload will be rejected. @type int $chunkSize If provided the upload will be done in chunks. The size must be in multiples of 262144 bytes. With chunking you have increased reliability at the risk of higher overhead. It is recommended to not use chunking. @type string $predefinedAcl Predefined ACL to apply to the object. Acceptable values include `"authenticatedRead`", `"bucketOwnerFullControl`", `"bucketOwnerRead`", `"private`", `"projectPrivate`", and `"publicRead"`. **Defaults to** `"private"`. @type array $metadata The available options for metadata are outlined at the [JSON API docs](https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request-body). @type string $encryptionKey A base64 encoded AES-256 customer-supplied encryption key. @type string $encryptionKeySHA256 Base64 encoded SHA256 hash of the customer-supplied encryption key. This value will be calculated from the `encryptionKey` on your behalf if not provided, but for best performance it is recommended to pass in a cached version of the already calculated SHA. }
return Google\Cloud\Upload\ResumableUploader
    public function getResumableUploader($data, array $options = [])
    {
        if (is_string($data) && !isset($options['name'])) {
            throw new \InvalidArgumentException('A name is required when data is of type string.');
        }
        return $this->connection->insertObject($this->formatEncryptionHeaders($options) + ['bucket' => $this->identity['bucket'], 'data' => $data, 'resumable' => true]);
    }

Usage Example

 /**
  * @expectedException InvalidArgumentException
  */
 public function testGetResumableUploaderWithStringWithNoName()
 {
     $bucket = new Bucket($this->connection->reveal(), 'bucket');
     $bucket->getResumableUploader('some more data');
 }