📝AWS S3

The module that provides the AWS S3 service.

Imports

import { AwsS3Service } from 'niro-health';

Method of Use

To use this module, you need to inject it into the desired service.

import { Module } from '@nestjs/common';
import {
  AwsS3Service,
  AwsCoreService,
  AwsConfigurationService,
  AwsStsService,
  ConfigurationService,
  ValidatorRegexpService,
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IAwsS3Service',
      useClass: AwsS3Service,
    },
    {
      provide: 'IAwsCoreService',
      useClass: AwsCoreService,
    },
    {
      provide: 'IAwsConfigurationService',
      useClass: AwsConfigurationService,
    },
    {
      provide: 'IAwsStsService',
      useClass: AwsStsService,
    },
    {
      provide: 'IConfigurationService',
      useClass: ConfigurationService,
    },
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}

Injecting the module into our service.

import { Inject, Injectable } from '@nestjs/common';
import type { IAwsS3Service } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IAwsS3Service')
    private readonly awsS3Service: IAwsS3Service,
  ) {}

  async getFile() {
    return await this.awsS3Service.get('my-photo', 'png', 1, 'my-bucket');
  }
}

With dependencies

You will need to inject the following interfaces.

Interface
Service

IAwsCoreService

IConfigurationService

IValidatorRegexpService

IStringExService

IAwsConfigurationService

IAwsStsService

Methods

Method
Scope
Description

client

public

Get the AWS S3 client.

setRole3rdParty

public

Set the role 3rd party.

upload

public

Upload a file to S3.

get

public

Get a file from S3.

delete

public

Delete a file from S3.

Last updated