Storage/src/StorageObject.php
public function rename($name, array $options = [])
    {
        $destinationBucket = isset($options['destinationBucket'])
            ? $options['destinationBucket']
            : $this->identity['bucket'];
        unset($options['destinationBucket']);

        $copiedObject = $this->copy($destinationBucket, [
            'name' => $name
        ] + $options);

        $this->delete(
            array_intersect_key($options, [
                'restOptions' => null,
                'retries' => null
            ])
        );
        $this->info = [];

        return $copiedObject;
    }
public function rename($name, array $options = [])
    {
        $destinationBucket = isset($options['destinationBucket'])
            ? $options['destinationBucket']
            : $this->identity['bucket'];
        unset($options['destinationBucket']);

        $copiedObject = $this->copy($destinationBucket, [
            'name' => $name
        ] + $options);

        $this->delete(
            array_intersect_key($options, [
                'restOptions' => null,
                'retries' => null
            ])
        );
        $this->info = [];

        return $copiedObject;
    }
public function rename ( $ name , array $ options = [ ] ) { $ destinationBucket = isset ( $ options [ 'destinationBucket' ] ) ? $ options [ 'destinationBucket' ] : $ this -> identity [ 'bucket' ] ; unset ( $ options [ 'destinationBucket' ] ) ; $ copiedObject = $ this -> copy ( $ destinationBucket , [ 'name' => $ name ] + $ options ) ; $ this -> delete ( array_intersect_key ( $ options , [ 'restOptions' => null , 'retries' => null ] ) ) ; $ this -> info = [ ] ; return $ copiedObject ; }
Renames the object.

Please note that there is no atomic rename provided by the Storage API.
This method is for convenience and is a set of sequential calls to copy
and delete. Upon success the source object's metadata will be cleared,
please use the returned object instead.

Example:
```
$object2 = $object->rename('object2.txt');
echo $object2->name();
```

@param string $name The new name.
@param array $options [optional] {
Configuration options.

@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.
@type string $destinationBucket Will move to this bucket if set. If
not set, will default to the same bucket.
}
@return StorageObject The renamed object.
Renames the object .