MaiXinRong 5 سال پیش
والد
کامیت
cd84ea4aeb
2فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 2 2
      app/controller/sign_controller.js
  2. 4 4
      app/controller/stage_controller.js

+ 2 - 2
app/controller/sign_controller.js

@@ -51,9 +51,9 @@ module.exports = app => {
             try {
                 const stream = await ctx.getFileStream({ requireFile: false });
                 const create_time = Date.parse(new Date()) / 1000;
-                const dirName = '/upload/sign/';
+                const dirName = 'app/public/upload/sign/';
                 const fileName = moment().format('YYYYMMDD') + '_sign_' + create_time + '.png';
-                await ctx.helper.saveStreamFile(stream, path.join(this.app.config.filePath, dirName, fileName));
+                await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
                 await sendToWormhole(stream);
 
                 const result = await ctx.service.projectAccount.update({ sign_path: fileName }, { id: stream.fields.id });

+ 4 - 4
app/controller/stage_controller.js

@@ -570,8 +570,8 @@ module.exports = app => {
                 const stream = await ctx.getFileStream();
                 const create_time = Date.parse(new Date()) / 1000;
                 const fileInfo = path.parse(stream.filename);
-                const fileName = path.join('upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + fileInfo.ext);
-                await ctx.helper.saveStreamFile(stream, path.join(this.app.config.filePath, fileName));
+                const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + fileInfo.ext);
+                await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, fileName));
                 ctx.body = {err: 0, msg: '', data: fileName};
             } catch(err) {
                 this.log(err);
@@ -592,10 +592,10 @@ module.exports = app => {
 
                 if (data.updateType === 'update') {
                     const create_time = Date.parse(new Date()) / 1000;
-                    const fileName = path.join('upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.jpg');
+                    const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.jpg');
                     const base64Data = data.img.replace(/^data:image\/\w+;base64,/, "");
                     const dataBuffer = new Buffer(base64Data, 'base64');
-                    await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.config.filePath, fileName));
+                    await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.baseDir, 'app', fileName));
                     data.calc_img = fileName;
                     data.calc_img_org = JSON.stringify(data.imgInfo);
                     delete data.updateType;