multi-downloader-client/README.md

66 lines
1.2 KiB
Markdown
Raw Normal View History

2024-01-11 10:16:15 +00:00
# multi-downloader-client
2024-01-11 10:04:42 +00:00
## Installation
2024-01-11 14:23:45 +00:00
Add repository in composer.json
2024-01-11 10:04:42 +00:00
```json
{
"repositories": [{
"type": "composer",
"url": "https://git.nwb.fr/api/packages/modules-communs-php/composer"
}
]
}
```
2024-01-11 14:23:45 +00:00
Then run composer require
2024-01-11 10:04:42 +00:00
```bash
2024-01-11 10:16:15 +00:00
composer require nwb/multi-downloader-client
2024-01-11 10:04:42 +00:00
```
2024-01-11 14:23:45 +00:00
## Env
The following env variables are used by default
```dotenv
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 )
2024-01-11 14:23:45 +00:00
```
They can be overriden in the constructor
```php
use Nwb\MultiDownloaderClient\MultiDownloaderClient;
$client = new MultiDownloaderClient([
'apiKey' => '',
'url' => '',
])
```
## Usage
Ajouter des fichiers
```php
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
```php
$zip = $client->downloadAsString();
```
Save zip to file (stream)
```php
$client->downloadTo('/tmp/my-zip.zip');
```
Get html form
```php
$form = $client->htmlForm();
```