Skip to content
Permalink
1ba7dc68c3
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
23 lines (20 sloc) 699 Bytes
'use strict'
const Article = require('../modules/article')
const ifs = require('../modules/imagefs')
const editPost = async(ctx, dbName) => {
try {
const body = ctx.request.body
const id = body.id
console.log(id)
console.log(body)
const article = await new Article(dbName)
await article.reupload(id, body.title, body.summary, body.content, body.tag)
const {path, type} = ctx.request.files.image
await ifs.deletePicture(`public/articleImages/${id}.png`)
await ifs.uploadPicture(path, type, `${id}`, 'public/articleImages/' )
ctx.redirect(`/?msg=new "${body.title}" uploaded`)
} catch(err) {
await ctx.render('error', {message: err.message})
}
}
module.exports = editPost