Socket
Socket
Sign inDemoInstall

multer-sharp-minio-storage

Package Overview
Dependencies
150
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    multer-sharp-minio-storage

Streaming multer storage engine with Sharp image transformer for MinIO.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

multer-sharp-minio-storage

Streaming multer storage engine with Sharp image transformer for MinIO.

Installation

npm install multer-sharp-minio-storage@latest

Usage

import multer from 'multer'
import path from 'path'
import sharp from 'sharp'
import slugify from 'slugify'
import MulterSharpMinioStorage from 'multer-sharp-minio-storage'

const upload = multer({
  storage: new MulterSharpMinioStorage({
    filename: (_req, file, t) => {
      const name = path.parse(file.originalname).name
      return slugify(name, { lower: true, trim: true }) + '_' + Date.now() + '_' + t.id + '.jpg'
    },
    meta: (_req, _file, _t) => ({ 'Content-Type': 'image/jpeg' }),
    bucket: process.env.S3_BUCKET,
    transformers: [
      {
        id: '320',
        sharp: sharp().resize(320).jpeg()
      },
      {
        id: '640',
        sharp: sharp().resize(640).jpeg()
      }
    ],
    clientOptions: {
      endPoint: process.env.S3_ENDPOINT,
      accessKey: process.env.S3_ACCESS_KEY_ID,
      secretKey: process.env.S3_SECRET_ACCESS_KEY
    }
  })
})

export const uploadImage = upload.single('file')

Keywords

FAQs

Last updated on 01 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc