Skip to content

Instantly share code, notes, and snippets.

@shelwinnn
Forked from romainneutron/gist:5340930
Last active August 29, 2015 14:26
Show Gist options
  • Save shelwinnn/b3a13eefbf4a3bfb4308 to your computer and use it in GitHub Desktop.
Save shelwinnn/b3a13eefbf4a3bfb4308 to your computer and use it in GitHub Desktop.
Download large files using Guzzle
<?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