Storage/src/StorageObject.php
public function copy($destination, array $options = [])
    {
        $key = isset($options['encryptionKey']) ? $options['encryptionKey'] : null;
        $keySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null;

        $response = $this->connection->copyObject(
            $this->formatDestinationRequest($destination, $options)
        );

        return new StorageObject(
            $this->connection,
            $response['name'],
            $response['bucket'],
            $response['generation'],
            $response + ['requesterProjectId' => $this->identity['userProject']],
            $key,
            $keySHA256
        );
    }
public function copy($destination, array $options = [])
    {
        $key = isset($options['encryptionKey']) ? $options['encryptionKey'] : null;
        $keySHA256 = isset($options['encryptionKeySHA256']) ? $options['encryptionKeySHA256'] : null;

        $response = $this->connection->copyObject(
            $this->formatDestinationRequest($destination, $options)
        );

        return new StorageObject(
            $this->connection,
            $response['name'],
            $response['bucket'],
            $response['generation'],
            $response + ['requesterProjectId' => $this->identity['userProject']],
            $key,
            $keySHA256
        );
    }
public function copy ( $ destination , array $ options = [ ] ) { $ key = isset ( $ options [ 'encryptionKey' ] ) ? $ options [ 'encryptionKey' ] : null ; $ keySHA256 = isset ( $ options [ 'encryptionKeySHA256' ] ) ? $ options [ 'encryptionKeySHA256' ] : null ; $ response = $ this -> connection -> copyObject ( $ this -> formatDestinationRequest ( $ destination , $ options ) ) ; return new StorageObject ( $ this -> connection , $ response [ 'name' ] , $ response [ 'bucket' ] , $ response [ 'generation' ] , $ response + [ 'requesterProjectId' => $ this -> identity [ 'userProject' ] ] , $ key , $ keySHA256 ) ; }
Copy the object to a destination bucket.

Please note that if the destination bucket is the same as the source
bucket and a new name is not provided the source object will be replaced
with the copy of itself.

Example:
```
// Provide your destination bucket as a string and retain the source
// object's name.
$copiedObject = $object->copy('otherBucket');
```

```
// Provide your destination bucket as a bucket object and choose a new
// name for the copied object.
$otherBucket = $storage->bucket('otherBucket');
$copiedObject = $object->copy($otherBucket, [
'name' => 'newFile.txt'
]);
```

@see https://cloud.google.com/storage/docs/json_api/v1/objects/copy Objects copy API documentation.

@param Bucket|string $destination The destination bucket.
@param array $options [optional] {
Configuration options.

@type string $name The name of the destination object. **Defaults
to** the name of the source object.
@type string $predefinedAcl Predefined ACL to apply to the object.
Acceptable values include, `"authenticatedRead"`,
`"bucketOwnerFullControl"`, `"bucketOwnerRead"`, `"private"`,
`"projectPrivate"`, and `"publicRead"`.
@type string $encryptionKey A base64 encoded AES-256 customer-supplied
encryption key. It will be neccesary to provide this when a key
was used during the object's creation.
@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.
@type string $ifGenerationMatch Makes the operation conditional on
whether the destination object's current generation matches the
given value.
@type string $ifGenerationNotMatch Makes the operation conditional on
whether the destination object's current generation does not
match the given value.
@type string $ifMetagenerationMatch Makes the operation conditional
on whether the destination object's current metageneration
matches the given value.
@type string $ifMetagenerationNotMatch Makes the operation
conditional on whether the destination object's current
metageneration does not match the given value.
@type string $ifSourceGenerationMatch Makes the operation conditional
on whether the source object's current generation matches the
given value.
@type string $ifSourceGenerationNotMatch Makes the operation
conditional on whether the source object's current generation
does not match the given value.
@type string $ifSourceMetagenerationMatch Makes the operation
conditional on whether the source object's current
metageneration matches the given value.
@type string $ifSourceMetagenerationNotMatch Makes the operation
conditional on whether the source object's current
metageneration does not match the given value.
}
@return StorageObject
Copy the object to a destination bucket .