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