How to use the @nestjs/platform-express.FilesInterceptor function in @nestjs/platform-express

To help you get started, we’ve selected a few @nestjs/platform-express examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danielwii / asuna-node-server / src / modules / core / uploader / controller.ts View on Github external
* @param files
   */
  @ApiBearerAuth()
  @ApiOperation({ summary: 'Upload files' })
  @ApiConsumes('multipart/form-data')
  @ApiQuery({
    name: 'local',
    enum: ['1'],
    required: false,
    description: 'force use local storage',
  })
  @UseGuards(AnyAuthGuard)
  @Post()
  @UseInterceptors(
    // new FastifyFileInterceptor('files'),
    FilesInterceptor('files', configLoader.loadNumericConfig(ConfigKeys.UPLOADER_MAX_COUNT, 3), fileInterceptorOptions),
  )
  async uploader(
    @Query('bucket') bucket = '',
    @Query('prefix') prefix = '',
    @Query('local') local: string, // 是否使用本地存储
    @Req() req: AnyAuthGuard,
    @UploadedFiles() files,
  ): Promise {
    /*
    if (req.fileValidationError) {
      throw new UploadException(req.fileValidationError);
    } */
    logger.log(`upload files ${r({ bucket, prefix, files })}`);
    const results = await this.saveFiles(bucket, prefix, local, files).catch(error => {
      logger.error(`upload files ${r({ bucket, prefix, files })} error: ${r(error)}`);
      // fs.rmdir(tempFolder).catch(reason => logger.warn(r(reason)));
github vellengs / nestx / packages / servers / nestx-cms / src / controllers / media.controller.ts View on Github external
@Query("value") value?: string
  ): Promise {
    return this.service.search(keyword, value);
  }

  @Post("upload")
  @UseInterceptors(FileInterceptor("file"))
  async uploadFile(@UploadedFile() file: MediaFile): Promise {
    return {
      ok: true,
      file: file.path
    };
  }

  @Post("uploads")
  @UseInterceptors(FilesInterceptor("files"))
  async uploadFiles(
    @UploadedFiles() files?: MediaFile[]
  ): Promise {
    const fileNames = (files || []).map(item => item.path);
    return {
      ok: true,
      files: fileNames
    };
  }

  @Post()
  async create(@Body() entry: CreateMediaDto): Promise {
    return this.service.create(entry);
  }

  @Put()
github vellengs / nestx-server / packages / cms / src / controllers / media.controller.ts View on Github external
@Query("value") value?: string
  ): Promise {
    return this.service.search(keyword, value);
  }

  @Post("upload")
  @UseInterceptors(FileInterceptor("file"))
  async uploadFile(@UploadedFile() file: MediaFile): Promise {
    return {
      ok: true,
      file: file.path
    };
  }

  @Post("uploads")
  @UseInterceptors(FilesInterceptor("files"))
  async uploadFiles(
    @UploadedFiles() files?: MediaFile[]
  ): Promise {
    const fileNames = (files || []).map(item => item.path);
    return {
      ok: true,
      files: fileNames
    };
  }

  @Post()
  async create(@Body() entry: CreateMediaDto): Promise {
    return this.service.create(entry);
  }

  @Put()
github vellengs / nestx / packages / server / src / cms / controllers / media.controller.ts View on Github external
@Query('value') value?: string,
  ): Promise {
    return this.service.search(keyword, value);
  }

  @Post('upload')
  @UseInterceptors(FileInterceptor('file'))
  async uploadFile(@UploadedFile() file: MediaFile): Promise {
    return {
      ok: true,
      file: file.path,
    };
  }

  @Post('uploads')
  @UseInterceptors(FilesInterceptor('files'))
  async uploadFiles(
    @UploadedFiles() files?: MediaFile[],
  ): Promise {
    const fileNames = (files || []).map(item => item.path);
    return {
      ok: true,
      files: fileNames,
    };
  }

  @Post()
  async create(@Body() entry: CreateMediaDto): Promise {
    return this.service.create(entry);
  }

  @Put()

@nestjs/platform-express

Nest - modern, fast, powerful node.js web framework (@platform-express)

MIT
Latest version published 13 days ago

Package Health Score

98 / 100
Full package analysis

Similar packages