Go to file
Mathieu 767a246419
All checks were successful
continuous-integration/drone/push Build is passing
Merge branch 'main' of ssh://git.nwb.fr:22050/modules-communs-php/multi-downloader-client
2024-01-12 14:59:05 +00:00
.devcontainer Update devcontainer.json and MultiDownloaderClient.php 2024-01-12 09:52:27 +00:00
.vscode formatter 2024-01-12 12:28:53 +00:00
src array_filter 2024-01-12 14:58:00 +00:00
tests FileOptions class 2024-01-12 14:00:06 +00:00
.drone.yml Initial commit 2024-01-11 10:04:42 +00:00
.gitignore Add composer.lock to .gitignore 2024-01-12 07:56:41 +00:00
composer.json version 2024-01-12 14:58:22 +00:00
phpcs.xml Initial commit 2024-01-11 10:04:42 +00:00
phpunit.xml Initial commit 2024-01-11 10:04:42 +00:00
README.md Fix missing comma in MultiDownloaderClient instantiation 2024-01-12 15:18:32 +01:00

multi-downloader-client

Installation

Add repository in composer.json

{
    "repositories": [{
            "type": "composer",
            "url": "https://git.nwb.fr/api/packages/modules-communs-php/composer"
        }
    ]
}

Then run composer require

composer require nwb/multi-downloader-client

Env

The following env variables are used by default

MULTI_DOWNLOADER_ACCESS_KEY
MULTI_DOWNLOADER_SECRET_KEY
MULTI_DOWNLOADER_URL (Utile en cas de test local. Si non précisée: https://multi-dl.kub.nwb.fr )

They can be overriden in the constructor

use Nwb\MultiDownloaderClient\MultiDownloaderClient;

$client = new MultiDownloaderClient([
    'apiKey' => '',
    'apiSecret' => '',
    'url' => '',
]);

Usage

Ajouter des fichiers

use Nwb\MultiDownloaderClient\MultiDownloaderClient;
use Nwb\MultiDownloaderClient\FileRequest;

$client = new MultiDownloaderClient();

$client->addFiles([
    new FileRequest('http://example.com/image.png'),
    new FileRequest('http://example.com/image1.png')
]);

Get zip as string

$zip = $client->downloadAsString();

Save zip to file (stream)

$client->downloadTo('/tmp/my-zip.zip');

Get html form

$form = $client->htmlForm();

Rename files inside zip

$file = new FileRequest('http://example.com/image.png');
$file->getFileOptions()->name('new-name.png');