-
-
Save shelwinnn/b3a13eefbf4a3bfb4308 to your computer and use it in GitHub Desktop.
Download large files using Guzzle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Guzzle\Http\Client; | |
require __DIR__ . '/vendor/autoload.php'; | |
$tmpFile = tempnam(sys_get_temp_dir(), 'guzzle-download'); | |
$handle = fopen($tmpFile, 'w'); | |
$client = new Client('', array( | |
Client::CURL_OPTIONS => array( | |
'CURLOPT_RETURNTRANSFER' => true, | |
'CURLOPT_FILE' => $handle | |
) | |
)); | |
$client->get('http://domain.tld/large-file.mp4')->send(); | |
fclose($handle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment