|
@@ -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('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + fileInfo.ext);
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, 'app', 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));
|
|
|
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('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + '.jpg');
|
|
|
+ const fileName = path.join('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.baseDir, 'app', fileName));
|
|
|
+ await this.ctx.helper.saveBufferFile(dataBuffer, path.join(this.app.config.filePath, fileName));
|
|
|
data.calc_img = fileName;
|
|
|
data.calc_img_org = JSON.stringify(data.imgInfo);
|
|
|
delete data.updateType;
|
|
@@ -1191,17 +1191,17 @@ module.exports = app => {
|
|
|
if (!stream.filename) {
|
|
|
throw '请选择上传的文件!';
|
|
|
}
|
|
|
- const dirName = 'app/public/upload/stage/' + moment().format('YYYYMMDD');
|
|
|
+ const dirName = '/upload/stage/' + moment().format('YYYYMMDD');
|
|
|
// 判断文件夹是否存在,不存在则直接创建文件夹
|
|
|
- if (!fs.existsSync(path.join(this.app.baseDir, dirName))) {
|
|
|
- await fs.mkdirSync(path.join(this.app.baseDir, dirName));
|
|
|
+ if (!fs.existsSync(path.join(this.app.config.filePath, dirName))) {
|
|
|
+ await fs.mkdirSync(path.join(this.app.config.filePath, dirName));
|
|
|
}
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
const fileName = 'stage' + create_time + '_' + index + fileInfo.ext;
|
|
|
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.helper.saveStreamFile(stream, path.join(this.app.config.filePath, dirName, fileName));
|
|
|
|
|
|
if (stream) {
|
|
|
await sendToWormhole(stream);
|
|
@@ -1251,7 +1251,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
const fileInfo = await ctx.service.stageAtt.getDataById(id);
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
|
- const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ const fileName = path.join(this.app.config.filePath, fileInfo.filepath);
|
|
|
// 解决中文无法下载问题
|
|
|
const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
let disposition = '';
|
|
@@ -1297,7 +1297,7 @@ module.exports = app => {
|
|
|
const fileInfo = await ctx.service.stageAtt.getDataById(data.id);
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
|
// 先删除文件
|
|
|
- await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
|
|
|
+ await fs.unlinkSync(path.join(this.app.config.filePath, fileInfo.filepath));
|
|
|
// 再删除数据库
|
|
|
await ctx.service.stageAtt.deleteById(data.id);
|
|
|
responseData.data = '';
|
|
@@ -1338,15 +1338,15 @@ module.exports = app => {
|
|
|
if (stream.filename !== undefined) {
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
- const dirName = 'app/public/upload/stage/' + moment().format('YYYYMMDD');
|
|
|
+ const dirName = '/upload/stage/' + moment().format('YYYYMMDD');
|
|
|
const fileName = 'stage' + create_time + fileInfo.ext;
|
|
|
|
|
|
// 判断文件夹是否存在,不存在则直接创建文件夹
|
|
|
- if (!fs.existsSync(path.join(this.app.baseDir, dirName))) {
|
|
|
- await fs.mkdirSync(path.join(this.app.baseDir, dirName));
|
|
|
+ if (!fs.existsSync(path.join(this.app.config.filePath, dirName))) {
|
|
|
+ await fs.mkdirSync(path.join(this.app.config.filePath, dirName));
|
|
|
}
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.helper.saveStreamFile(stream, path.join(this.app.config.filePath, dirName, fileName));
|
|
|
// 保存数据到att表
|
|
|
fileData = {
|
|
|
filesize: stream.fields.size,
|
|
@@ -1398,15 +1398,15 @@ module.exports = app => {
|
|
|
throw '请选择上传的文件!';
|
|
|
}
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
- const dirName = 'app/public/upload/pay/' + moment().format('YYYYMMDD');
|
|
|
+ const dirName = '/upload/pay/' + moment().format('YYYYMMDD');
|
|
|
const fileName = 'pay' + create_time + '_' + index + fileInfo.ext;
|
|
|
|
|
|
// 判断文件夹是否存在,不存在则直接创建文件夹
|
|
|
- if (!fs.existsSync(path.join(this.app.baseDir, dirName))) {
|
|
|
- await fs.mkdirSync(path.join(this.app.baseDir, dirName));
|
|
|
+ if (!fs.existsSync(path.join(this.app.config.filePath, dirName))) {
|
|
|
+ await fs.mkdirSync(path.join(this.app.config.filePath, dirName));
|
|
|
}
|
|
|
// 保存文件
|
|
|
- await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, dirName, fileName));
|
|
|
+ await ctx.helper.saveStreamFile(stream, path.join(this.app.config.filePath, dirName, fileName));
|
|
|
await sendToWormhole(stream);
|
|
|
// 插入到stage_pay对应的附件列表中
|
|
|
const attData = {
|
|
@@ -1453,7 +1453,7 @@ module.exports = app => {
|
|
|
const payInfo = await ctx.service.stagePay.getDataById(id);
|
|
|
if (payInfo !== undefined && payInfo.attachment !== null) {
|
|
|
const fileInfo = JSON.parse(payInfo.attachment)[index];
|
|
|
- const fileName = path.join(this.app.baseDir, fileInfo.filepath);
|
|
|
+ const fileName = path.join(this.app.config.filePath, fileInfo.filepath);
|
|
|
// 解决中文无法下载问题
|
|
|
const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
|
|
|
let disposition = '';
|
|
@@ -1500,7 +1500,7 @@ module.exports = app => {
|
|
|
if (payInfo !== undefined) {
|
|
|
const fileInfo = JSON.parse(payInfo.attachment)[data.index];
|
|
|
// 先删除文件
|
|
|
- await fs.unlinkSync(path.join(this.app.baseDir, fileInfo.filepath));
|
|
|
+ await fs.unlinkSync(path.join(this.app.config.filePath, fileInfo.filepath));
|
|
|
// 再删除数据库
|
|
|
const attachment = JSON.parse(payInfo.attachment);
|
|
|
attachment.splice(data.index, 1);
|