@nailyjs.nest.modules/ali-oss
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

☁️ ali-oss SDK for nest.js

A aliyun OSS SDK for nest.js.

Installation

pnpm i @nailyjs.nest.modules/ali-oss

Usage

import { Module } from '@nestjs/common';
import { AliOSSModule } from '@nailyjs.nest.modules/ali-oss';

@Module({
  imports: [
    AliOSSModule.forRoot(/* options */),
  ],
})
export class AppModule {}

You can also use AliOSSModule.forRootAsync to provide options asynchronously.

import { Module } from '@nestjs/common';
import { AliOSSModule } from '@nailyjs.nest.modules/ali-oss';

@Module({
  imports: [
    AliOSSModule.forRootAsync({
      useFactory: () => ({/* options */}),
    }),
  ],
})
export class AppModule {}

Then you can use AliOSSService to upload files.

import { Injectable } from '@nestjs/common';
import { AliOSSService } from '@nailyjs.nest.modules/ali-oss';

@Injectable()
export class AppService {
  constructor(private readonly aliOSSService: AliOSSService) {}
}

Multiple AliOSS Instances

You can create multiple AliOSS instances with different configurations.

import { Module } from '@nestjs/common';
import { AliOSSModule } from '@nailyjs.nest.modules/ali-oss';

@Module({
  imports: [
    AliOSSModule.forRoot([
      {
        provide: 'AliOSSInstanceName1',
        /* options */
      },
      {
        provide: 'AliOSSInstanceName2',
        /* options */
      }
    ]),
  ],
})
export class AppModule {}

Then you can use AliOSSService with a specific name.

import { Injectable, Inject } from '@nestjs/common';
import { AliOSSService } from '@nailyjs.nest.modules/ali-oss';

@Injectable()
export class AppService {
  constructor(
    @Inject('AliOSSInstanceName1') private readonly aliOSSService1: AliOSSService,
    @Inject('AliOSSInstanceName2') private readonly aliOSSService2: AliOSSService,
  ) {}
}

Author

👤 Naily Zero

License

MIT

/@nailyjs.nest.modules/ali-oss/

    Package Sidebar

    Install

    npm i @nailyjs.nest.modules/ali-oss

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    21.7 kB

    Total Files

    20

    Last publish

    Collaborators

    • guhuan