# multiple-downloads-one-zip

> A JavaScript module to download multiple files and zip them

Latest version **0.1.4** (published 2023-11-07) · 0 weekly downloads

## Install

```sh
npm install multiple-downloads-one-zip
pnpm add multiple-downloads-one-zip
yarn add multiple-downloads-one-zip
bun add multiple-downloads-one-zip
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2023-11-07 |
| First published | 2020-05-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 16.13.0 |
| Dependencies | 1 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | loicosiewe16 |

## Links

- npm: https://www.npmjs.com/package/multiple-downloads-one-zip
- Repository: https://github.com/williamsiewe16/multiple-downloads-one-zip
- Homepage: https://github.com/williamsiewe16/multiple-downloads-one-zip#readme
- Issues: https://github.com/williamsiewe16/multiple-downloads-one-zip/issues
- npm.io page: https://npm.io/package/multiple-downloads-one-zip

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.19.2

## Recent versions

- 0.1.4 (latest) — 2023-11-07
- 0.1.3 — 2023-11-07
- 0.1.2 — 2020-05-17
- 0.1.1 — 2020-05-16
- 0.1.0 — 2020-05-16

## README

# multiple-downloads-one-zip
A JavaScript module to download multiple files and zip them

### install
```
npm install multiple-downloads-one-zip --save 
```

## API
### ``.downloadAndZip(urls: string[], options?: DownloadOptions): void ``

An `async` function to download files located at different urls and put them in a zip

```javascript
 type DownloadOptions = {
    zip_name ?: string,     // Name of the zip file generated. Spaces in the name are replaced by `_`
    zip_dir ?: string,     // Directory where the file will be located. It must be an existing directory
    file_extension ?: string,     // Files extension. The value "jpg" is used by default
    onFileComplete ?: (info: FileCompleteInfo) => void,
    onEnd ?: (info: DownloadEnd) => void
 };
```

if  `options.onFileComplete` is provided, il will be called when a file is fully downloaded and passed an argument with a single property:

```javascript 
 type FileCompleteInfo = {
    complete: boolean     // A boolean returning true 
 } 
```

if  `options.onEnd` is provided, il will be called when all downloads are completed and passed an argument with a single property:

```javascript 
 type DownloadEnd = {
    zip_path: string,     // Path of the zip file
 }
```


#### Examples

```javascript  
  // require the module
  let download = require('multiple-downloads-one-zip')
  
  // Urls where files are downloaded from
  let urls = [
            "http://i996.imggur.net/hunter-x-hunter/390/hunter-x-hunter-11553019.jpg",
            "http://i996.imggur.net/hunter-x-hunter/390/hunter-x-hunter-11553025.jpg",
        ]

  let zip_name = "myZip" // avoid spaces
  let zip_dir = "." // give an existing directory
  
  // download and zip the files
  //  Since it is an async function, we must put `await` before, and the function must be called in an `async` function
  await download.downloadAndZip(urls,{
    zip_name: zip_name,
    zip_dir: zip_dir,
    onEnd: (data) => {
       // do what we want with the data containing the zip path
    },
    onFileComplete: (data) => {
        // do what we want
    }
 })
```

---
_Source: https://npm.io/package/multiple-downloads-one-zip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
