# @ynspc/image-upload

> A basic package to work with file upload criteria.

Latest version **0.1.0** (published 2023-12-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ynspc/image-upload
pnpm add @ynspc/image-upload
yarn add @ynspc/image-upload
bun add @ynspc/image-upload
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-12-25 |
| First published | 2023-03-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 38 KB |
| Known vulnerabilities | 0 (+16 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Yathartha Shrestha |
| Maintainers | yathartha |
| Keywords | file upload, pre signed url, s3 bucket, nodejs |

## Links

- npm: https://www.npmjs.com/package/@ynspc/image-upload
- Repository: https://github.com/ynspc/ynspc-upload
- Homepage: https://github.com/ynspc/ynspc-upload#readme
- Issues: https://github.com/ynspc/ynspc-upload/issues
- npm.io page: https://npm.io/package/@ynspc/image-upload

## Dependencies (8)

- [sharp](https://npm.io/package/sharp.md) ^0.31.3
- [multer](https://npm.io/package/multer.md) 1.4.5-lts.1
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1334.0
- [envalid](https://npm.io/package/envalid.md) ^7.3.1
- [express](https://npm.io/package/express.md) ^4.18.2
- [fluent-ffmpeg](https://npm.io/package/fluent-ffmpeg.md) ^2.1.2
- [@google-cloud/storage](https://npm.io/package/@google-cloud/storage.md) ^7.7.0
- [@ffmpeg-installer/ffmpeg](https://npm.io/package/@ffmpeg-installer/ffmpeg.md) ^1.1.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-12-25
- 0.0.8 — 2023-12-22
- 0.0.7 — 2023-12-19
- 0.0.6 — 2023-03-11
- 0.0.5 — 2023-03-11
- 0.0.4 — 2023-03-11
- 0.0.3 — 2023-03-11
- 0.0.2 — 2023-03-07
- 0.0.1 — 2023-03-07

## README

# ynspc-upload

### Installation

    yarn add @ynspc/image-upload

    npm install @ynspc/image-upload

    pnpm add @ynspc/image-upload

```
const { manageConfiguration, manageFileNaming } = require("@ynspc/image-upload")
const ynspcImageUpload = require("@ynspc/image-upload").default

const config = manageConfiguration([{
    field: "logos",
    config: {
        message: "You need to upload a valid file.",
        extensions: [".jpg", ".png"]
    }
}])
const uploadImage = new ynspcImageUpload("storage/logos")
try {
    const response = await uploadImage.singleUpload("logos", req, res, config)
    console.log(response)
}
catch(exception) {
    console.log("error", exception)
}
```

***Note***
```
app.use((err, req, res, next) => {
    ======Multer error handling======
    if (err.storageErrors !== undefined){
        req.resume()
    }
    ==================================
    
    return res
        .status(412)
        .json({ 
            result: 'fail', 
            error: { 
                code: 1001,
                detail: err.message
            }
        }, 412)
})
```

***Environment Config***
```
STORAGE= <storage>[aws, local]
ACCESS_KEY= <Your_access_key>
SECRET_KEY= <Your secret key>
BUCKET_NAME= <Your bucket name>
REGION= <Your region name>
SIGNATURE_VERSION= <Signature version>
SIGNED_URL_EXPIRY= <Signed url expiry>
AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1
```

---
_Source: https://npm.io/package/@ynspc/image-upload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
