...
|
...
|
@@ -29,14 +29,18 @@ class FileController extends Context { |
|
|
}
|
|
|
|
|
|
req.body.files = [];
|
|
|
const bucket = req.body.bucket;
|
|
|
_.each(files, file => {
|
|
|
const types = file.type.split('/');
|
|
|
|
|
|
// add support for pdf
|
|
|
const isPdf = /pdf/i.test(file.type || '');
|
|
|
if (isPdf) {
|
|
|
// 5M
|
|
|
if (file.size > 5 * 1024 * 1024) {
|
|
|
if (bucket === 'invoices') {
|
|
|
// 上传 pdf, pdf大小限制500k
|
|
|
const isPDF = /pdf/i.test(file.type || '');
|
|
|
if (!isPDF) {
|
|
|
errTip = '上传文件格式不正确';
|
|
|
}
|
|
|
|
|
|
if (file.size > 500 * 1024) {
|
|
|
errTip = '上传文件尺寸太大!';
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -63,16 +67,16 @@ class FileController extends Context { |
|
|
});
|
|
|
}
|
|
|
|
|
|
if (req.body.bucket === 'goodsimg' || req.body.bucket === 'invoice') {
|
|
|
if (bucket === 'goodsimg' || bucket === 'invoices') {
|
|
|
this.api
|
|
|
.upload('http://upload.static.yohobuy.com', {
|
|
|
fileData: req.body.files,
|
|
|
project: req.body.bucket,
|
|
|
project: bucket,
|
|
|
})
|
|
|
.then(result => {
|
|
|
if (result.code === 200 && _.get(result, 'data.imagesList.length', 0)) {
|
|
|
result.data.imagesList = _.map(result.data.imagesList, imgUrl => {
|
|
|
return this.fileService.getAbsoluteUrl(imgUrl, req.body.bucket);
|
|
|
return this.fileService.getAbsoluteUrl(imgUrl, bucket);
|
|
|
});
|
|
|
}
|
|
|
res.json(result);
|
...
|
...
|
@@ -82,7 +86,7 @@ class FileController extends Context { |
|
|
this.api
|
|
|
.upload(apiDomain.platform.uploads, {
|
|
|
files: req.body.files,
|
|
|
bucket: req.body.bucket,
|
|
|
bucket,
|
|
|
})
|
|
|
.then(result => {
|
|
|
const newResult = {
|
...
|
...
|
|