import { Controller , Post , UploadedFile , UploadedFiles , UseInterceptors , } from '@nestjs/common' ; import { FileInterceptor } from '@nestjs/platform-express' ; import { Express } from 'express' ; import { ApiBearerAuth , ApiTags } from '@nestjs/swagger' ; import { staticBaseUrl } from './constants' ; @ ApiTags ( '文件上传' ) @ ApiBearerAuth ( ) @ Controller ( 'upload' ) export class UploadController { @ Post ( 'file' ) @ UseInterceptors ( FileInterceptor ( 'file' ) ) uploadFile ( @ UploadedFile ( ) file ) { return { file : staticBaseUrl + file . originalname , } ; } @ Post ( 'files' ) @ UseInterceptors ( FileInterceptor ( 'files' ) ) uploadFiles ( @ UploadedFiles ( ) files ) { return { files : files . map ( ( f ) => staticBaseUrl + f . originalname ) , } ; } }