Toggle navigation
Toggle navigation
This project
Loading...
Sign in
MotherProject
/
myYoutube
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Flare-k
2020-06-24 03:51:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ac8ed02068ae27ed0331258df7f3d00d16cf699
6ac8ed02
1 parent
bd523a95
[Add] AWS Service
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
controllers/userController.js
controllers/videoController.js
middlewares.js
views/mixins/videoPlayer.pug
controllers/userController.js
View file @
6ac8ed0
...
...
@@ -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
)
{
...
...
controllers/videoController.js
View file @
6ac8ed0
...
...
@@ -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
,
...
...
middlewares.js
View file @
6ac8ed0
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"
;
...
...
views/mixins/videoPlayer.pug
View file @
6ac8ed0
mixin videoPlayer(video={})
.videoPlayer#jsVideoPlayer
video(src=
`/${video.src}`
)
video(src=
video.src
)
.videoPlayer__controls
.videoPlayer__column
span#jsVolumeBtn
...
...
Please
register
or
login
to post a comment