primipilus/downloader

download file

Installs: 2 518

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/primipilus/downloader

v2.0.2 2018-01-17 11:18 UTC

This package is auto-updated.

Last update: 2025-10-15 01:44:23 UTC


README

Composer install

composer require "primipilus/downloader:~2.0"

Usage

try {
    $downloader = \primipilus\downloader\Downloader::getInstance('http', ['temporaryDir' => __DIR__, 'attempts' => 5]);
} catch (BaseException $e) {
}

$client = new FtpClient\FtpClient();
try {
    $downloader = \primipilus\downloader\Downloader::getInstance('ftp', ['temporaryDir' => __DIR__, 'attempts' => 5, 'client' => $client]);
} catch (BaseException $e) {
}

if ($downloader) {
    $file = $downloader->downloadFile($fileFrom);
    
    echo $file->getOriginal(), PHP_EOL;
    echo $file->getInfo()->path, PHP_EOL;
    echo $file->getInfo()->basename, PHP_EOL;
    echo $file->getInfo()->filename, PHP_EOL;
    echo $file->getInfo()->extension, PHP_EOL;
    if ($file->getInfo()->isImage) {
        echo $file->getInfo()->image->width . ' px', PHP_EOL;
        echo $file->getInfo()->image->height . ' px', PHP_EOL;
    }
}