multi-downloader-client/README.md
Mathieu 345e6a0c51
All checks were successful
continuous-integration/drone/push Build is passing
fileOptions
2024-01-12 13:06:39 +00:00

74 lines
1.4 KiB
Markdown

# multi-downloader-client
## Installation
Add repository in composer.json
```json
{
"repositories": [{
"type": "composer",
"url": "https://git.nwb.fr/api/packages/modules-communs-php/composer"
}
]
}
```
Then run composer require
```bash
composer require nwb/multi-downloader-client
```
## 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 )
```
They can be overriden in the constructor
```php
use Nwb\MultiDownloaderClient\MultiDownloaderClient;
$client = new MultiDownloaderClient([
'apiKey' => '',
'apiSecret' => '',
'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();
```
Rename files inside zip
```php
$file = (new FileRequest('http://example.com/image.png'))
->fileOptions([
'name' => 'my-new-name.png'
]);
```