From 7aa85737caa50a45cc5f6f42d79fc5ac1703e515 Mon Sep 17 00:00:00 2001 From: SeonWoo KIm Date: Thu, 13 Oct 2022 14:52:47 +0000 Subject: [PATCH] =?UTF-8?q?[#44]=20Comment:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +---- backend/src/loaders/multer.js | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index db28e9a..5fd7ab6 100644 --- a/.gitignore +++ b/.gitignore @@ -104,7 +104,4 @@ dist .tern-port # JSDoc output files -/backend/out - -# Uploaded image files -/backend/public/images \ No newline at end of file +/backend/out \ No newline at end of file diff --git a/backend/src/loaders/multer.js b/backend/src/loaders/multer.js index 82eb736..45b492b 100644 --- a/backend/src/loaders/multer.js +++ b/backend/src/loaders/multer.js @@ -8,6 +8,7 @@ dotenv.config(); const IMAGE_PATH = path.resolve('./public/images'); +// 디렉토리가 없을 경우 경로에 새로운 디렉토리 추가 try { fs.readdirSync(IMAGE_PATH); } catch (error) { @@ -15,7 +16,9 @@ try { fs.mkdirSync(IMAGE_PATH, { recursive: true }); } - +/** + * 파일의 저장경로 및 파일이름 생성 규칙 정의 + */ const storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, IMAGE_PATH);