From ccd4dbe694e43806f9dc69b5292a327d69550667 Mon Sep 17 00:00:00 2001 From: Chip Wasson Date: Mon, 11 Dec 2023 23:07:57 -0700 Subject: [PATCH] Move upload form --- src/file/file.controller.ts | 13 ++++++++++++- views/file/upload.hbs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/file/file.controller.ts b/src/file/file.controller.ts index 056f9df..29f24ae 100644 --- a/src/file/file.controller.ts +++ b/src/file/file.controller.ts @@ -22,7 +22,7 @@ export class FileController { return { url } } - @Post() + @Post('upload') @UseInterceptors(FileInterceptor('file')) @ApiConsumes('multipart/form-data') @Render('file/upload-result') @@ -33,4 +33,15 @@ export class FileController { expireTime: new Date(upload.expireAt * 1000).toLocaleString(), } } + + @Post('upload.json') + @UseInterceptors(FileInterceptor('file')) + @ApiConsumes('multipart/form-data') + async handleFileUploadJson(@UploadedFile() file: Express.Multer.File): Promise { + const upload = await this.fileService.handleFileUpload(file); + return { + ...upload, + expireTime: new Date(upload.expireAt * 1000).toLocaleString(), + } + } } diff --git a/views/file/upload.hbs b/views/file/upload.hbs index 543f79e..247d309 100644 --- a/views/file/upload.hbs +++ b/views/file/upload.hbs @@ -1,4 +1,4 @@ -
+