From d09bb4b68846fe788adce567351b12a7401d35c6 Mon Sep 17 00:00:00 2001 From: Brock Anderson Date: Thu, 12 Dec 2024 13:39:31 -0800 Subject: [PATCH] create read stream from a verified path string --- backend/src/v1/middlewares/storage/upload.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/v1/middlewares/storage/upload.ts b/backend/src/v1/middlewares/storage/upload.ts index 9655c006..bba08529 100644 --- a/backend/src/v1/middlewares/storage/upload.ts +++ b/backend/src/v1/middlewares/storage/upload.ts @@ -1,15 +1,15 @@ -import fs from 'fs'; -import { logger } from '../../../logger'; import { PutObjectCommand, PutObjectCommandInput, S3Client, } from '@aws-sdk/client-s3'; -import os from 'os'; import retry from 'async-retry'; -import { S3_BUCKET, S3_OPTIONS } from '../../../constants/admin'; +import fs from 'fs'; +import os from 'os'; import PATH from 'path'; import { v4 as uuidv4 } from 'uuid'; +import { S3_BUCKET, S3_OPTIONS } from '../../../constants/admin'; +import { logger } from '../../../logger'; interface Options { folder: string; @@ -41,7 +41,7 @@ export const useUpload = (options: Options) => { res.end(); return; } - const stream = fs.createReadStream(path); + const stream = fs.createReadStream(filePath); const uploadParams: PutObjectCommandInput = { Bucket: S3_BUCKET, Key: `${options.folder}/${data.attachmentId}/${uuidv4()}.${ext}`,