1.1.2 • Published 1 month ago

@namatery/multer-minio v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

MinIO

A simple Storage Engine for Minio to upload files there in the middleware level with Multer. To write you own Storage Engine check out this page.

How to install it?

To use this package you can easily install it via npm:

npm install @namatery/multer-minio

How to use it?

NOTE 1: multer-minio is just a storage engine for Multer package so you need to first install it vie this link.

NOTE 2: multer-minio needs an instance of Client class to connect to Minio. For more information see Minio API Document.

MinioStorageEngine

A a class that you can import it from @namatery/multer-minio:

const { Client } = require('minio');
const { MinioStorageEngine } = require('@namatery/multer-minio');

const minioClient = new Client({
  port: PORT,
  endPoint: END_POINT,
  accessKey: ACCESS_KEY,
  secretKey: SECRET_KEY,
});

const options = {
  path: '/path/in/bucket',
  region: 'us-east-1',
  bucket: {
    init: true,
    versioning: false,
    forceDelete: false,
  },
  object: {
    name: (req, file) => {
      return `${new Date()}-${file.originalname}`;
    },
    useOriginalFilename: false,
  },
};

const storage = new MinioStorageEngine(minioClient, 'test', options);

Options

NameDescriptionRequiredDefault
pathThe path of file in the bucket.False/
regionRegion where the bucket is created.Falseus-east-1
bucket.initIf ture the bucket is create if not exists.FalseFalse
bucket.versioningCan be Enabled or Suspended.FalseFalse
bucket.forceDeleteIf true objects will remove even if versioning was enabled.FalseFalse
object.nameCan be null or a function that return name of the object.Falseuuid
object.useOriginalFilenameIf true name of the original file will be use.FalseFalse

Example

Checkout this link to see a full example:

comment: <> (Links)

1.1.2

1 month ago

1.1.1

7 months ago