Authored by Targaryen

add-user

... ... @@ -21,10 +21,11 @@ class FileApi {
/**
* 上传到服务器的文件处理
* @param {文件} file
* @param {路径} actPath
* @param {文件} file
* @param {路径} actPath
* @param {用户} user
*/
async upload(file, actPath) {
async upload(file, actPath, user) {
let fileName = _.get(file, 'name');
let fileNameWithoutType = _.split(fileName, '.')[0];
let fileSavePath = path.join(FILE_SAVE_ROOT_PATH, fileName); // 文件保存到服务器的路径
... ... @@ -71,7 +72,8 @@ class FileApi {
date: moment().format('YYYY-MM-DD HH:mm'),
fileName: fileName,
actPath: actPath,
username: '' // TODO
username: user.username,
user_id: user._id
});
await this._uploadToQiniu(fileList, fileDistPath);
... ...
... ... @@ -91,6 +91,7 @@ const file = {
if ('POST' !== ctx.method) return await next();
let file = _.get(ctx, 'request.body._files.file');
let user = ctx.session.user;
if (!file) {
return ctx.body = {
... ... @@ -108,7 +109,7 @@ const file = {
};
}
await new FileApi().upload(file, actPath);
await new FileApi().upload(file, actPath, user);
return ctx.body = {
code: 200,
... ...