Skip to content

Commit e899075

Browse files
committed
added ability to guess filenames based on content-type header
1 parent 575cbfe commit e899075

File tree

6 files changed

+833
-3
lines changed

6 files changed

+833
-3
lines changed

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Download large files using PHP and cURL
22

3-
There's too many code snippets on the Internet on how to do this, but not enough libraries. So I made this.
3+
There's too many code snippets on the Internet on how to do this, but not enough libraries.
4+
5+
This will allow you to download files of any size using cURL without ever running out of memory. That's it.
46

57
```php
68
<?php
@@ -11,11 +13,18 @@ use CurlDownloader\CurlDownloader;
1113
$browser = new Client();
1214
$downloader = new CurlDownloader($browser);
1315

14-
$downloader->download("https://download.ccleaner.com/cctrialsetup.exe", function ($filename) {
16+
$response = $downloader->download("https://download.ccleaner.com/cctrialsetup.exe", function ($filename) {
1517
return './2020-06-07-' . $filename;
1618
});
19+
20+
if ($response->status == 200) {
21+
// 28,851,928 bytes downloaded in 20.041231 seconds
22+
echo number_format($response->info->size_download) . ' bytes downloaded in ' . $response->info->total_time . ' seconds';
23+
}
1724
```
1825

26+
It will automatically guess filename of the resource being downloaded (just like web-browsers do it!) with an option to override it if needed.
27+
1928
## Installation
2029

2130
```bash
@@ -24,5 +33,6 @@ composer require athlon1600/php-curl-file-downloader
2433

2534
### Links
2635

36+
- https://github.com/Athlon1600/php-curl-client
2737
- https://demo.borland.com/testsite/download_testpage.php
2838

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "athlon1600/php-curl-file-downloader",
33
"require": {
4-
"athlon1600/php-curl-client": "^1.0"
4+
"athlon1600/php-curl-client": "^1.0",
5+
"ext-curl": "*"
56
},
67
"require-dev": {
78
"phpunit/phpunit": "^7.0"

0 commit comments

Comments
 (0)