Skip to content

Commit

Permalink
#61 s3에 이미지 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
kth2624 committed May 27, 2022
1 parent 83ed7a9 commit 781e9d1
Show file tree
Hide file tree
Showing 6 changed files with 354 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ dist
uploads/
.vscode

awsconfig.json
2 changes: 1 addition & 1 deletion controller/board.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function upload(req, res, err) {
console.log(image.length);
console.log(req.fileValidationError);
console.log(image[0]);
const path = image.map(img => img.path);
const path = image.map(img => img.location);
console.log(`path = ${path}`);
if(req.fileValidationError){//파일이 크거나 형식이 다를때
return res.status(400).send({message: req.fileValidationError});
Expand Down
6 changes: 3 additions & 3 deletions data/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ export async function findByCommentId(id) {

export async function imageUpload(boardId, images) {
const values = images.map(image => {
return [boardId, `${config.serverUrl.serverUrl}${image.path}`, image.originalname, image.mimetype, image.size]
return [boardId, image.location, image.originalname, image.mimetype, image.size, image.key]
})
console.log(values);
console.log(`value : ${values}`);
return db
.query('INSERT INTO image_info (boardNum, filePath, fileName, fileType, fileSize) VALUES ?',
.query('INSERT INTO image_info (boardNum, filePath, fileName, fileType, fileSize, fileKey) VALUES ?',
[values])
.then((result) => result[0]);
}
Expand Down
Loading

0 comments on commit 781e9d1

Please sign in to comment.