|
@@ -286,11 +286,25 @@ export class VideoMediaController {
|
|
|
@Post('import/excel-tags')
|
|
@Post('import/excel-tags')
|
|
|
async importExcelTags(@Req() req: FastifyRequest) {
|
|
async importExcelTags(@Req() req: FastifyRequest) {
|
|
|
// fastify multipart
|
|
// fastify multipart
|
|
|
- const part = await (req as any).file();
|
|
|
|
|
- if (!part) throw new BadRequestException('No file uploaded');
|
|
|
|
|
|
|
+ const reqAny = req as any;
|
|
|
|
|
+ const bodyFile = reqAny.body?.file;
|
|
|
|
|
+ let mpFile = Array.isArray(bodyFile) ? bodyFile[0] : bodyFile;
|
|
|
|
|
+ if (!mpFile && reqAny.isMultipart?.()) {
|
|
|
|
|
+ mpFile = await reqAny.file();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const buf = await part.toBuffer();
|
|
|
|
|
- if (!buf?.length) throw new BadRequestException('Empty file');
|
|
|
|
|
|
|
+ if (!mpFile) {
|
|
|
|
|
+ throw new BadRequestException('No file uploaded');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const buf =
|
|
|
|
|
+ typeof mpFile.toBuffer === 'function'
|
|
|
|
|
+ ? await mpFile.toBuffer()
|
|
|
|
|
+ : mpFile.buffer;
|
|
|
|
|
+
|
|
|
|
|
+ if (!buf?.length) {
|
|
|
|
|
+ throw new BadRequestException('Empty file');
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return this.videoMediaService.importExcelTags(buf);
|
|
return this.videoMediaService.importExcelTags(buf);
|
|
|
}
|
|
}
|