Flare-k

[Add] AWS Service

......@@ -153,7 +153,7 @@ export const postEditProfile = async (req, res) => {
await User.findByIdAndUpdate(req.user.id, {
name,
email,
avatarUrl: file ? file.path : req.user.avatarUrl,
avatarUrl: file ? file.location : req.user.avatarUrl, // S3 적용때메 file.path -> file.location 변경(06/24)
});
res.redirect(routes.me);
} catch (error) {
......
......@@ -40,11 +40,11 @@ export const postUpload = async (req, res) => {
// 이는 pug와 db.js를 확인해야하는 듯 하다.
const {
body: { title, description },
file: { path },
file: { location }, // path로 할때는 로컬의 경로. S3는 location
} = req; // file에 path라는 요소가 있다.
const newVideo = await Video.create({
fileUrl: path,
fileUrl: location,
title,
description,
creator: req.user.id,
......
import dotenv from "dotenv";
import multer from "multer";
import multerS3 from "multer-s3";
import aws from "aws-sdk";
import routes from "./routes";
const multerVideo = multer({ dest: "uploads/videos/" });
const multerAvatar = multer({ dest: "uploads/avatars/" });
dotenv.config();
const s3 = new aws.S3({
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_PRIVATEE_KEY,
region: "ap-northeast-2",
});
// const multerVideo = multer({ dest: "uploads/videos/" });
const multerVideo = multer({
storage: multerS3({
s3,
acl: "public-read",
bucket: "khutube/video",
}),
});
// const multerAvatar = multer({ dest: "uploads/avatars/" });
const multerAvatar = multer({
storage: multerS3({
s3,
acl: "public-read",
bucket: "khutube/avatars",
}),
});
export const localsMiddleware = (req, res, next) => {
res.locals.siteName = "my Youtube";
......
mixin videoPlayer(video={})
.videoPlayer#jsVideoPlayer
video(src=`/${video.src}`)
video(src=video.src)
.videoPlayer__controls
.videoPlayer__column
span#jsVolumeBtn
......