Storage/src/StorageObject.php
public function downloadToFile($path, array $options = [])
    {
        $destination = Psr7\stream_for(fopen($path, 'w'));

        Psr7\copy_to_stream(
            $this->downloadAsStream($options),
            $destination
        );

        $destination->seek(0);

        return $destination;
    }
public function downloadToFile($path, array $options = [])
    {
        $destination = Psr7\stream_for(fopen($path, 'w'));

        Psr7\copy_to_stream(
            $this->downloadAsStream($options),
            $destination
        );

        $destination->seek(0);

        return $destination;
    }
public function downloadToFile ( $ path , array $ options = [ ] ) { $ destination = Psr7 \ stream_for ( fopen ( $ path , 'w' ) ) ; Psr7 \ copy_to_stream ( $ this -> downloadAsStream ( $ options ) , $ destination ) ; $ destination -> seek ( 0 ) ; return $ destination ; }
Download an object to a specified location.

Example:
```
$stream = $object->downloadToFile(__DIR__ . '/my-file.txt');
```

@param string $path Path to download the file to.
@param array $options [optional] {
Configuration Options.

@type string $encryptionKey An AES-256 customer-supplied encryption
key. It will be neccesary to provide this when a key was used
during the object's creation. If provided one must also include
an `encryptionKeySHA256`.
@type string $encryptionKeySHA256 The SHA256 hash of the
customer-supplied encryption key. It will be neccesary to
provide this when a key was used during the object's creation.
If provided one must also include an `encryptionKey`.
}
@return StreamInterface
Download an object to a specified location .