-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multer loader에 uploadPostImage추가, image 라우터에 POST /image/upload 추가 Comment: image 라우터에 설명 주석 추가
- Loading branch information
inyeoptti
committed
Oct 13, 2022
1 parent
0fb490c
commit bbb0d81
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
import { Router } from "express"; | ||
import { uploadAvatar } from "../../loaders/multer"; | ||
import { uploadAvatar, uploadPostImage } from "../../loaders/multer"; | ||
|
||
const router = Router(); | ||
|
||
// POST /image/upload-avatar | ||
// Content-Type: multipart/form-data | ||
// Requires field(name=avatar) with image data | ||
router.post("/upload-avatar", uploadAvatar, (req, res) => { | ||
const { fieldname, originalname, encoding, mimetype, destination, filename, path, size } = req.file; | ||
|
||
res.json({path: `/public/${filename}`}); | ||
res.json({ path: `/public/${filename}` }); | ||
}); | ||
|
||
// POST /image/upload | ||
// Content-Type: multipart/form-data | ||
// Requires field(name=image) with image data | ||
router.post("/upload", uploadPostImage, (req, res) => { | ||
const { fieldname, originalname, encoding, mimetype, destination, filename, path, size } = req.file; | ||
|
||
res.json({ path: `/public/${filename}` }); | ||
}); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters