...
|
...
|
@@ -32,12 +32,26 @@ class FileController extends Context { |
|
|
_.each(files, file => {
|
|
|
const types = file.type.split('/');
|
|
|
|
|
|
if (!types || types[0] !== 'image') {
|
|
|
errTip = '上传文件格式不正确!';
|
|
|
// add support for pdf
|
|
|
const isPdf = /pdf/i.test(file.type || '');
|
|
|
if (isPdf) {
|
|
|
// 5M
|
|
|
if (file.size > 5 * 1024 * 1024) {
|
|
|
errTip = '上传文件尺寸太大!';
|
|
|
}
|
|
|
} else {
|
|
|
if (!types || types[0] !== 'image') {
|
|
|
errTip = '上传文件格式不正确!';
|
|
|
}
|
|
|
|
|
|
// 10M
|
|
|
if (file.size > 10 * 1024 * 1024) {
|
|
|
errTip = '上传文件尺寸太大!';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (file.size > 10 * 1024 * 1024) {
|
|
|
errTip = '上传文件尺寸太大!';
|
|
|
if (errTip) {
|
|
|
return false; // return early
|
|
|
}
|
|
|
req.body.files.push(fs.createReadStream(file.path));
|
|
|
req.body.files.push(file.name);
|
...
|
...
|
@@ -49,7 +63,7 @@ class FileController extends Context { |
|
|
});
|
|
|
}
|
|
|
|
|
|
if (req.body.bucket === 'goodsimg') {
|
|
|
if (req.body.bucket === 'goodsimg' || req.body.bucket === 'invoice') {
|
|
|
this.api
|
|
|
.upload('http://upload.static.yohobuy.com', {
|
|
|
fileData: req.body.files,
|
...
|
...
|
|