The `nestjs-minio-client` package provides a robust integration of the Minio S3-compatible object storage client into the NestJS framework. It offers a `MinioModule` for streamlined configuration and registration, supporting both synchronous `register()` and asynchronous `registerAsync()` methods, which is particularly useful for injecting configuration from NestJS's `@nestjs/config` package. An injectable `MinioService` then provides direct access to the underlying Minio JS SDK client instance, allowing developers to interact with Minio's API. The current stable version is 2.2.0, with a consistent release cadence focusing on updates to dependencies, NestJS compatibility, and internal refactoring. It serves as a dedicated wrapper, simplifying Minio usage within NestJS applications and abstracting away direct SDK initialization. It requires NestJS version 9 or later.
npm install nestjs-minio-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates registering the `MinioModule` asynchronously using `@nestjs/config` to load Minio credentials from environment variables, and then injecting and using `MinioService` in another service to list buckets and simulate a file upload operation.
Review your module registration code and ensure it aligns with the examples provided in the v2.x documentation, especially if upgrading from v1.x.
Carefully consider the implications of using `MinioModule.register({ global: true })`. For better architectural clarity and testability, import `MinioModule` into specific feature modules where its services are consumed.Ensure your NestJS project is running version 9.0.0 or higher. Update your `@nestjs/common` and `@nestjs/core` packages if necessary.
Consult the official Minio Javascript SDK documentation for specific API calls (e.g., `putObject`, `getObject`, `listBuckets`) and their expected behaviors, parameters, and potential errors. Wrap SDK calls in `try...catch` blocks where appropriate.
Ensure `import { MinioModule } from 'nestjs-minio-client';` is present at the top of your module file (e.g., `app.module.ts`). Verify `nestjs-minio-client` is correctly installed in `node_modules`.When using `MinioModule.registerAsync` with `ConfigService`, ensure `imports: [ConfigModule]` is included in the `MinioModule.registerAsync` options object, and `ConfigModule.forRoot()` or `ConfigModule.forFeature()` is set up correctly in your application's root module.
Review the configuration object passed to `MinioModule.register()` or returned by `useFactory` in `MinioModule.registerAsync()`. Ensure `endPoint`, `port`, `accessKey`, and `secretKey` are all provided and correctly formatted.