修复文件上传

master
expressgy 2 years ago
parent 14ba1298e3
commit c4ed0dd2f6
  1. 17
      src/starlight/starlight.controller.ts

@ -7,6 +7,7 @@ import {
Param, Param,
Delete, Delete,
UseGuards, UseGuards,
Req,
} from '@nestjs/common'; } from '@nestjs/common';
import { StarlightService } from './starlight.service'; import { StarlightService } from './starlight.service';
import { CreateStarlightDto } from './dto/create-starlight.dto'; import { CreateStarlightDto } from './dto/create-starlight.dto';
@ -48,4 +49,20 @@ export class StarlightController {
remove(@Param('id') id: string) { remove(@Param('id') id: string) {
return this.starlightService.remove(+id); return this.starlightService.remove(+id);
} }
@Post('/file')
async upFile(@Req() request: any): Promise<string> {
const files = await request.saveRequestFiles();
console.log('FILE', files);
console.log(
'FILE:filepath',
files[0].filepath,
files[0].fieldname,
files[0].filename,
files[0].encoding,
files[0].mimetype,
// files[0].fields,
files[0].file.bytesRead,
);
return 'Hello World';
}
} }

Loading…
Cancel
Save