Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@ntegral/nestjs-s3
Advanced tools
Provides an injectable s3 client to provide s3 storage access from nestjs modules
Provides an injectable S3 client to provide s3 storage access from nestjs modules
@ntegral/nestjs-s3
implements a module, S3Module
, which when imported into
your nestjs project provides an S3 client to any class that injects it. This
lets AWS S3 be worked into your dependency injection workflow without having to
do any extra work outside of the initial setup.
npm install --save @ntegral/nestjs-s3 aws-sdk
The simplest way to use @ntegral/nestjs-s3
is to use S3Module.forRoot
import { Module } from '@nestjs-common';
import { S3Module } from '@ntegral/nestjs-s3';
@Module({
imports: [
S3Module.forRoot({
accessKeyId: 'aws_access_key_id',
secretAccessKey: 'aws_secret_access_key',
region?: 'aws_region_id',
sessionToken?: 'aws_session_token', | null,
apiVersion?: 's3_api_version' //based on s3 api version //
}),
],
})
export class AppModule {}
The async way @ntegral/nestjs-s3
is to use S3Module.forRootAsync
import { Module } from '@nestjs-common';
import { S3Module } from '@ntegral/nestjs-s3';
import { ConfigModule } from '@ntegral/nestjs-config';
import { ConfigService } from '@ntegral/nestjs-config';
@Module({
imports: [
S3Module.forRootAsync({
imports: [ConfigModule],
useFactory: async (cfg:ConfigService) => ({
accessKeyId: cfg.get('ACCESS_KEY_ID'),
secretAccessKey: 'AWS_SECRET_ACCESS_KEY'
}),
inject: [ConfigService],
})
]
})
export class AppModule {}
You can then inject the S3 client into any of your injectables by using a custom decorator
import { Injectable } from '@nestjs/common';
import { InjectS3 } from '@ntegral/nestjs-s3';
import * as S3 from 'aws-sdk/clients/s3';
@Injectable()
export class AppService {
public constructor(@InjectS3() private readonly client: S3) { }
upload(pdf) {
const params = {
ACL: 'public-read',
Body: pdf,
Bucket: process.env.BUCKET,
Key: uuidv4(),
ContentEncoding: 'base64',
ContentType: `application/pdf`
};
try {
const { Location, Key } = await this.client.upload(params).promise();
return Location;
} catch (error) {
console.log('ERROR S3 FILE UPLOAD => ', error);
}
}
}
I would greatly appreciate any contributions to make this project better. Please make sure to follow the below guidelines before getting your hands dirty.
git checkout -b my-branch
)Distributed under the ISC License. See LICENSE
for more information.
Copyright © 2020 Ntegral Inc.
FAQs
Provides an injectable s3 client to provide s3 storage access from nestjs modules
The npm package @ntegral/nestjs-s3 receives a total of 294 weekly downloads. As such, @ntegral/nestjs-s3 popularity was classified as not popular.
We found that @ntegral/nestjs-s3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.