Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박민정
/
We-Shop
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박민정
2021-06-09 23:27:46 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f3723cc1f194b5b21afdbcc63e8e678886355601
f3723cc1
2 parents
ef15502a
081e26d8
[merge] Merge client to develop
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
We-Shop/server/index.js
We-Shop/server/routes/productImage.js
We-Shop/uploads/1623248422816_스크린샷 2021-06-09 오전 2.20.18.png
We-Shop/server/index.js
View file @
f3723cc
...
...
@@ -8,7 +8,7 @@ const cors = require('cors')
// body-parser 가져옴
const
bodyParser
=
require
(
'body-parser'
)
// bodyParser option
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
//application/x-www-form-urlencoded로 된 데이터를 분석해서 가져옴
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
//application/x-www-form-urlencoded로 된 데이터를 분석해서 가져옴
app
.
use
(
bodyParser
.
json
())
// application/json 타입으로 된 데이터를 분석해서 가져옴
const
cookieParser
=
require
(
"cookie-parser"
);
app
.
use
(
cookieParser
());
...
...
@@ -32,8 +32,7 @@ app.use(cors())
app
.
use
(
'/api/users'
,
require
(
'./routes/users'
));
app
.
use
(
'/api/product'
,
require
(
'./routes/product'
));
// 이미지 가져오려고
// 업로드 하려고
app
.
use
(
'/uploads'
,
express
.
static
(
'uploads'
));
if
(
process
.
env
.
NODE_ENV
===
"production"
)
{
...
...
@@ -43,6 +42,7 @@ if (process.env.NODE_ENV === "production") {
});
}
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server ---> http://localhost:
${
port
}
`
)
});
\ No newline at end of file
});
...
...
We-Shop/server/routes/productImage.js
0 → 100644
View file @
f3723cc
const
express
=
require
(
'express'
);
const
{
User
}
=
require
(
"../models/User"
);
const
{
auth
}
=
require
(
"../middleware/auth"
);
const
router
=
express
.
Router
();
var
storage
=
multer
.
diskStorage
({
destination
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
'uploads/'
)
// 어느 폴더에 저장할건지
},
filename
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
Date
.
now
()
+
'_'
+
file
.
originalname
)
// 이미지 이름
}
})
var
upload
=
multer
({
storage
:
storage
})
router
.
post
(
'/image'
,
(
req
,
res
)
=>
{
// 클라이언트로부터 받은 이미지 저장
upload
(
req
,
res
,
err
=>
{
if
(
err
)
return
req
.
json
({
success
:
false
,
err
})
return
res
.
json
({
success
:
true
,
filePath
:
res
.
req
.
file
.
path
,
fileName
:
res
.
req
.
file
.
filename
})
}
)
})
module
.
exports
=
router
;
We-Shop/uploads/1623248422816_스크린샷 2021-06-09 오전 2.20.18.png
0 → 100644
View file @
f3723cc
295 KB
Please
register
or
login
to post a comment