1.0.0 • Published 1 year ago
@mahyar-kd/nestjs-minio v1.0.0
Description
This's a nest-minio module for Nest. This quickstart guide will show you how to install the client SDK and execute an example JavaScript program. For a complete list of APIs and examples, please take a look at the JavaScript Client API Reference documentation.
This document assumes that you have a working nodejs setup in place.
Installation
$ npm i --save @mahyar--kd/nestjs-minio
or
$ yarn add @mahyar--kd/nestjs-minioInitialize MinIO Client
You need five items in order to connect to MinIO object storage server.
| Params | Description |
|---|---|
| endPoint | URL to object storage service. |
| port | TCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs. |
| accessKey | Access key is like user ID that uniquely identifies your account. |
| secretKey | Secret key is the password to your account. |
| useSSL | Set this value to 'true' to enable secure (HTTPS) access |
Provide the credentials for minio module by importing it as :
import { Module } from '@nestjs/common';
import { NestMinioClientController } from './nest-minio-client.controller';
import { MinioModule } from '@mahyar--kd/nestjs-minio';
import { ConfigService } from '@nestjs/config';
@Module({
controllers: [NestMinioClientController],
imports: [
MinioModule.forRootAsync({
imports: [],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
endPoint: configService.get('minio.endpoint'),
port: configService.get('minio.port'),
accessKey: configService.get('minio.accessKey'),
secretKey: configService.get('minio.secretKey'),
useSSL: configService.get('minio.useSSL'),
defaultBucket: configService.get('minio.bucket'),
}),
}),
],
})
export class NestMinioClientModule {}Then you can use it in the service by injecting it in the service as:
constructor(
@Inject(MINIO_CONNECTION)
private readonly minioService: MinioService,
) {}1.0.0
1 year ago