Go to file
Nicolas COMPAIN 037ed54ed9
All checks were successful
continuous-integration/drone/push Build is passing
Add apiSecret to MultiDownloaderClient constructor
2024-01-12 10:33:24 +00:00
.devcontainer Update devcontainer.json and MultiDownloaderClient.php 2024-01-12 09:52:27 +00:00
.vscode Compatibilité PHP 7 2024-01-12 10:04:08 +00:00
src Compatibilité PHP 7 2024-01-12 10:04:08 +00:00
tests Refactor MultiDownloaderClientTest class and update constructor usage 2024-01-12 09:46:25 +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 Update description and version in composer.json 2024-01-12 10:08:51 +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 Add apiSecret to MultiDownloaderClient constructor 2024-01-12 10:33:24 +00: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();