primipilus/downloader

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

This package is auto-updated.

Last update: 2024-04-14 22:23:55 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;
    }
}