From f245f06647a25d5fbf6a1cca6087b5a60cb64f47 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 17 Jul 2023 17:56:20 -0600 Subject: [PATCH] feat: attach file size to AssFile --- backend/routers/index.ts | 6 +++++- common/types.d.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/routers/index.ts b/backend/routers/index.ts index ac72591..68fa47f 100644 --- a/backend/routers/index.ts +++ b/backend/routers/index.ts @@ -48,6 +48,9 @@ router.post('/', async (req, res) => { try { + // Get the file size + const fileSize = (await fs.stat(bbFile.file)).size; + // * Move the file if (!s3) await fs.move(bbFile.file, destination); else await uploadFileS3(await fs.readFile(bbFile.file), bbFile.mimetype, fileKey); @@ -61,7 +64,8 @@ router.post('/', async (req, res) => { timestamp, uploader: '0', // todo: users save: {}, - sha256: '0' // todo: hashing + sha256: '0', // todo: hashing + size: fileSize }; // Set the save location diff --git a/common/types.d.ts b/common/types.d.ts index 9c895a5..776ea12 100644 --- a/common/types.d.ts +++ b/common/types.d.ts @@ -127,6 +127,7 @@ declare module 'ass' { } | true; } sha256: string; + size: number; timestamp: string; uploader: NID; }