明树Git Lab

Commit a52fcf71 authored by zengfanpei's avatar zengfanpei

upload

parent 2d3cc0c9
const ExcelJS = require('exceljs'); const ExcelJS = require('exceljs');
const path = require('path'); const _ = require('lodash');
async function upload(req, res, next) { async function upload(req, res, next) {
try { try {
// console.log(req.file, req.body); // console.log(req.file, req.body);
let path = _.last(String(req.file.path).split('/mnt/vdb1'));
let ret = await DB.File.create({ let ret = await DB.File.create({
originalname: req.file.originalname, originalname: req.file.originalname,
mimetype: req.file.mimetype, mimetype: req.file.mimetype,
filename: req.file.filename, filename: req.file.filename,
path: req.file.path, path,
originalpath: req.file.path,
size: req.file.size, size: req.file.size,
}); });
res.sendData(ret); res.sendData(ret);
......
...@@ -26,6 +26,9 @@ const fileSchema = new Schema({ ...@@ -26,6 +26,9 @@ const fileSchema = new Schema({
path: { path: {
type: String, type: String,
}, },
originalpath: {
type: String,
},
......
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