ok-dev-up/image-downloader-from-url

Component for downloading images by URL

dev-master 2018-11-29 22:38 UTC

This package is auto-updated.

Last update: 2024-09-29 05:21:25 UTC


README

This is component for downloading images by URL from another servers.

Installation

The preferred way to install the component is through composer.

Either run

composer require ok/image-downloader-from-url

or add

"ok/image-downloader-from-url": "dev-master"

to the require section of your composer.json.

Using

Create component instance

$downloader = new \ok\ImageDownloader([
    'class' => \ok\validators\ImageValidator::class
]);

in array you should specify the validator class. It used for validation of downloaded files. If you don't want run validation, you can use a \ok\validators\FakeValidator::class.

Then you should call method for downloading

$downloader->download($url, $imagesRoot, $file_name);

this method takes as agruments: URL to image, path to catalog where file will be saved and name for downloaded file.