小修改

This commit is contained in:
赵鑫 2022-08-26 23:51:32 +08:00
parent 0ae0e1285b
commit ab862d08fd
2 changed files with 2 additions and 3 deletions

View File

@ -38,7 +38,7 @@ app.post('/upload', upload.single('file'), async (req, res) => {
} }
fs.unlinkSync(file_temp_path) // 删除临时文件 fs.unlinkSync(file_temp_path) // 删除临时文件
// 写入数据库 // 写入数据库
const filesharing = new Filesharing({ const file = await Filesharing.create({
md5, md5,
size: req.file.size, size: req.file.size,
encoding: req.file.encoding, encoding: req.file.encoding,
@ -47,7 +47,6 @@ app.post('/upload', upload.single('file'), async (req, res) => {
filename: Buffer.from(req.file.originalname, 'latin1').toString('utf8'), filename: Buffer.from(req.file.originalname, 'latin1').toString('utf8'),
password: req.body.password ? await bcrypt.hash(req.body.password, 16) : '', password: req.body.password ? await bcrypt.hash(req.body.password, 16) : '',
}) })
const file = await filesharing.save()
res.status(201).render('upload', { file }) res.status(201).render('upload', { file })
}) })
app.get('/file/:id', async (req, res) => { app.get('/file/:id', async (req, res) => {

View File

@ -17,7 +17,7 @@ html(lang='zh')
else else
for file in filesharing for file in filesharing
li li
a(href=`/file/${file.id}` target='_blank')= file.filename a(href=`/file/${file.id}`)= file.filename
if file.password if file.password
span   ㊙️ span   ㊙️
span.small   ( #{moment(file.createdAt).fromNow()}, #{file.downloads} 次下载 ) span.small   ( #{moment(file.createdAt).fromNow()}, #{file.downloads} 次下载 )