...
|
...
|
@@ -130,7 +130,25 @@ module.exports={ |
|
|
result={code: "501",message: "用户失效,请重新登录"};
|
|
|
return callback(null, result);
|
|
|
}
|
|
|
req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
|
|
|
|
|
var files = req.files.upfile;
|
|
|
console.log(req.files);
|
|
|
//判断是单张传还是多张传
|
|
|
var flag = Object.prototype.toString.call(files) === '[object Array]';
|
|
|
//如果是单张,则数组化
|
|
|
if (!flag) {
|
|
|
files = [];
|
|
|
files.push(req.files.upfile);
|
|
|
}
|
|
|
|
|
|
req.body.files = [];
|
|
|
req.body.fileNames = [];
|
|
|
for (var index = 0; index < files.length; index++) {
|
|
|
req.body.files[index] = fs.createReadStream(files[index].path);
|
|
|
req.body.fileNames[index] = files[index].filename;
|
|
|
}
|
|
|
|
|
|
// req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
|
|
req.body.bucket="goodsimg";
|
|
|
request.post({
|
|
|
url: "http://upload.static.yohobuy.com",
|
...
|
...
|
@@ -142,21 +160,27 @@ module.exports={ |
|
|
if (!error && httpResponse.statusCode == 200) {
|
|
|
var ret = JSON.parse(body);
|
|
|
if (ret.code === 200) {
|
|
|
var imgUrl = ret.data.imagesList[0];
|
|
|
imgUrl=Utils.joinImg(imgUrl);
|
|
|
result={};
|
|
|
result = [];
|
|
|
for (var i = 0; i < ret.data.imagesList.length; i++) {
|
|
|
var imgUrl = ret.data.imagesList[i];
|
|
|
var rest = {};
|
|
|
imgUrl = Utils.joinImg(imgUrl);
|
|
|
|
|
|
if(imgUrl){
|
|
|
result.originalName=Date.now();
|
|
|
result.name=Date.now();
|
|
|
result.url=imgUrl;
|
|
|
result.type=imgUrl.substring(imgUrl.lastIndexOf('.'));
|
|
|
result.state="SUCCESS";
|
|
|
rest.originalName = Date.now();
|
|
|
rest.name = Date.now();
|
|
|
rest.url = imgUrl;
|
|
|
rest.type = imgUrl.substring(imgUrl.lastIndexOf('.'));
|
|
|
rest.state = "SUCCESS";
|
|
|
|
|
|
}else{
|
|
|
result.state="FAIL";
|
|
|
rest.state = "FAIL";
|
|
|
}
|
|
|
result.push(rest);
|
|
|
}
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
downExcel:function(req, callback){
|
...
|
...
|
|