app
.route("/blog")
.get((req, res) =>
blog.find((err, data) => {
if (!err) {
res.send(data);
} else {
res.send(err);
}
})
)
.post( upload.array('photo',1), (req, res, next) => {
const newBlog = new blog({
blog_title: req.body.blog_title,
blog_content: req.body.blog_content,
photo: ******
});
newBlog.save((err,data) => {
if (data) {
console.log("successfully added new articles")
console.log(req.body)
console.log(req.files)
res.send(data);
} else {
res.send(err);
}
});
});
I use Multer to post photo into the aws s3 it successfully post but i want to save post photo file name to my database. please help
Top comments (0)