明树Git Lab

Commit fbd4a2bf authored by zengfanpei's avatar zengfanpei

update

parent 1dec7a9e
...@@ -18,6 +18,25 @@ async function upload(req, res, next) { ...@@ -18,6 +18,25 @@ async function upload(req, res, next) {
next(error); next(error);
} }
} }
async function batchUpload(req, res, next) {
try {
let ret = [];
for (let index = 0; index < req.files.length; index++) {
const element = req.files[index];
ret.push({
originalname: element.originalname,
mimetype: element.mimetype,
filename: element.filename,
path: element.path,
size: element.size,
})
}
let data = await DB.File.insertMany(ret);
res.sendData(data);
} catch (error) {
next(error);
}
}
...@@ -68,5 +87,6 @@ async function importExcel(req, res, next) { ...@@ -68,5 +87,6 @@ async function importExcel(req, res, next) {
module.exports = { module.exports = {
upload, upload,
batchUpload,
importExcel importExcel
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ const upload = multer({ storage: storage }) ...@@ -32,7 +32,7 @@ const upload = multer({ storage: storage })
router.post('/upload', upload.single('file'), fileController.upload); router.post('/upload', upload.single('file'), fileController.upload);
// router.post('/') router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
// 文件访问: 起nginx用以处理文件服务器。 // 文件访问: 起nginx用以处理文件服务器。
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment