New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@aginix/gcloud-storage

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aginix/gcloud-storage

Google Cloud Storage module for Nest framework (node.js)

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

Description

Google Cloud Storage Module for Nest.js Framework

Installation

$ yarn add @aginix/gcloud-storage

Examples

Default import

If you have bucket domain name you can config storageBaseUri.

import { Module } from '@nestjs/common';
import { GCloudStorageModule } from '@aginix/gcloud-storage';

@Module({
  imports: [
    GCloudStorageModule.withConfig({
      defaultBucketname: 'bucket.aginix.tech',
      storageBaseUri: 'bucket.aginix.tech',
    })
  ],
})
export class AppModule {}

Default import with asynchonous

import { Module } from '@nestjs/common';
import { GCloudStorageModule } from '@aginix/gcloud-storage';
import { ConfigService } from './config.service';
import { ConfigModule } from './config.module';

@Module({
  imports: [
    GCloudStorageModule.withConfigAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        defaultBucketname: config.get('GCS_BUCKET_NAME'),
        storageBaseUri: config.get('GCS_DOMAIN_NAME'),
      }),
      imports: [ConfigModule],
    })
  ],
})
export class AppModule {}

Store a file using the default config

import {
  Controller,
  Logger,
  Post,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import {
  GCloudStorageFileInterceptor,
  UploadedFileMetadata,
} from '@aginix/gcloud-storage';

@Controller()
export class AppController {
  
  @Post('gcs/upload')
  @UseInterceptors(
    GCloudStorageFileInterceptor('file'),
  )
  UploadedFilesUsingInterceptor(
    @UploadedFile()
    file: UploadedFileMetadata,
  ) {
    Logger.log(`Storage URL: ${file.storageUrl}`, 'AppController');
  }
}

Store a file using a specifig folder/prefix name

import {
  Controller,
  Logger,
  Post,
  UploadedFile,
  UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import {
  GCloudStorageFileInterceptor,
  UploadedFileMetadata,
} from '@aginix/gcloud-storage';

@Controller()
export class AppController {
  
  @Post('gcs/upload')
  @UseInterceptors(
    GCloudStorageFileInterceptor('file', undefined, { prefix: 'prefix/test' })
  )
  UploadedFilesUsingInterceptor(
    @UploadedFile()
    file: UploadedFileMetadata,
  ) {
    Logger.log(`Storage URL: ${file.storageUrl}`, 'AppController');
  }
}

FAQs

Package last updated on 30 Jan 2020

Did you know?

Socket

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.

Install

Related posts