# Mantiqh Resizer JS

## Developed by Mantiqh Technologies

### Basic Details

- Used for uploading files to **AWS S3**.
- Files are resized according to user-defined dimensions.
- Package uses **pnpm** as the package manager.

---

## Installation

```sh
npm i mantiqh-resizer-js
```

---

## Usage

```javascript
import { resizeAndUpload } from 'mantiqh-resizer-js'

// your backend code...

// File buffer received from multer
const fileBuffer = req.file.buffer

// Output key for storage location in S3
const outputKey = `uploads/${Date.now()}-${req.file.originalname}`

// Resize and upload to S3
const imageUrl = await resizeAndUpload(fileBuffer, 300, 300, outputKey)

console.log('Image URL:', imageUrl) // Returns a CloudFront URL

// your backend code...
```

After execution, you will receive a **URL** from **AWS CloudFront**.

---

## Requirements

Ensure you have the following **AWS credentials** set in a `.env` file:

```
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
S3_BUCKET=your-bucket-name
CLOUDFRONT_DOMAIN=your-cloudfront-domain
```
