Example:
$stream = $object->downloadToFile(__DIR__ . '/my-file.txt');
public downloadToFile ( string $path, array $options = [] ) : Psr\Http\Message\StreamInterface | ||
$path | string | Path to download the file to. |
$options | array | [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`. } |
리턴 | Psr\Http\Message\StreamInterface |
public function testDownloadsToFile() { $key = base64_encode('abcd'); $hash = base64_encode('1234'); $bucket = 'bucket'; $object = 'object.txt'; $stream = Psr7\stream_for($string = 'abcdefg'); $this->connection->downloadObject(['bucket' => $bucket, 'object' => $object, 'generation' => null, 'httpOptions' => ['headers' => ['x-goog-encryption-algorithm' => 'AES256', 'x-goog-encryption-key' => $key, 'x-goog-encryption-key-sha256' => $hash]]])->willReturn($stream); $object = new StorageObject($this->connection->reveal(), $object, $bucket); $this->assertEquals($string, $object->downloadToFile('php://temp', ['encryptionKey' => $key, 'encryptionKeySHA256' => $hash])->getContents()); }
public function testDownloadsToFile() { $stream = Psr7\stream_for($string = 'abcdefg'); $this->connection->downloadObject(Argument::any())->willReturn($stream); $object = new StorageObject($this->connection->reveal(), 'object.txt', 'bucket'); $this->assertEquals($string, $object->downloadToFile('php://temp')->getContents()); }