import { S3 } from "aws-sdk" ; import { Injectable , Inject } from "@nestjs/common" ; import { FileDiToken } from "../file.di" ; /**
 *  Incapsulates logic of S3 Storage requests. AWS S3 SDK Facade
 */ @ Injectable ( ) export class S3FileStorage { public constructor ( @ Inject ( FileDiToken . S3 ) private readonly s3 ) { } public upload ( config ) { return this . s3 . upload ( config ) . promise ( ) ; } public delete ( config ) { return this . s3 . deleteObject ( config ) . promise ( ) ; } public multipleDelete ( config ) { return this . s3 . deleteObjects ( config ) . promise ( ) ; } public getDirectUrl ( config ) { return this . s3 . getSignedUrl ( "getObject" , config ) ; } }