Skip to content
Permalink
55fbb47831
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
26 lines (23 sloc) 853 Bytes
'use strict'
const Article = require('../modules/article')
const ifs = require('../modules/imagefs')
const Image = require('../modules/image')
const categoriesTagGet = 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
const image = await new Image(dbName)
await ifs.deletePicture(`public/articleImages/${id}.png`)
await ifs.uploadPicture(path, type, `${id}`, 'public/articleImages/' )
await image.replace(`public/articleImages/${id}.png`)
ctx.redirect(`/?msg=new "${body.title}" uploaded`)
} catch(err) {
await ctx.render('error', {message: err.message})
}
}
module.exports = categoriesTagGet