0.0.8 • Published 4 years ago

nest-image-resizer v0.0.8

Weekly downloads
41
License
-
Repository
github
Last release
4 years ago

nestjs-image-resizer-upload

Resize and upload images to google cloud storage

install

  npm install --save 'nest-image-resizer'

setup

async import

YOUR_GOOGLE_CLOUD_CREDENTIALS = path to your google service account file that gives you permission to upload files to a bucket

@Module({
  imports: [
    ImageResizerModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory(config: ConfigService) {
        return {
          projectId: config.get('YOUR_GOOGLE_CLOUD_PROJECT_ID'),
          keyFilename: config.get('YOUR_GOOGLE_CLOUD_CREDENTIALS'),
          bucket: config.get('YOUR_GOOGLE_CLOUD_BUCKET_NAME'),
        };
      },
    }),
  ],
})

Using the service

import { ImageResizerService } from 'nest-image-resizer';

export class YourService {
  constructor(
    private readonly imageResizerService: ImageResizerService,
  ) {}
}