Created
April 8, 2013 21:59
-
-
Save romainneutron/5340930 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
I forked @devNoiseConsulting.
Check the complete code here
https://gist.github.com/skndrkhtr5/9ab734456a95dff5014e1f31a8ddcad0