Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junrillg/f1d6b2c05bf473c966947f2cc27815dc to your computer and use it in GitHub Desktop.
Save junrillg/f1d6b2c05bf473c966947f2cc27815dc 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