...
|
...
|
@@ -130,20 +130,31 @@ module.exports={ |
|
|
result={code: "501",message: "用户失效,请重新登录"};
|
|
|
return callback(null, result);
|
|
|
}
|
|
|
req.body.file = fs.createReadStream(req.files.upfile.path);
|
|
|
req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
|
|
req.body.bucket="goodsimg";
|
|
|
request.post({
|
|
|
url: config.domain + '/fileupload/upload',
|
|
|
formData: req.body
|
|
|
}, function optionalCallback(error, httpResponse, rebody) {
|
|
|
url: "http://upload.static.yohobuy.com",
|
|
|
formData: {
|
|
|
fileData: req.body.files,
|
|
|
project: req.body.bucket
|
|
|
}
|
|
|
}, function optionalCallback(error, httpResponse, body) {
|
|
|
if (!error && httpResponse.statusCode == 200) {
|
|
|
var json = JSON.parse(rebody);
|
|
|
result={};
|
|
|
result.originalName=json.data.substring(json.data.lastIndexOf('/')+1);
|
|
|
result.name=result.originalName;
|
|
|
result.url=json.data;
|
|
|
result.type=json.data.substring(json.data.lastIndexOf('.'));
|
|
|
result.state=json.message=="上传成功"?"SUCCESS":"FAIL";
|
|
|
var ret = JSON.parse(body);
|
|
|
if (ret.code === 200) {
|
|
|
var imgUrl = ret.data.imagesList[0];
|
|
|
imgUrl=Utils.joinImg(imgUrl);
|
|
|
result={};
|
|
|
if(imgUrl){
|
|
|
result.originalName=Date.now();
|
|
|
result.name=Date.now();
|
|
|
result.url=imgUrl;
|
|
|
result.type=imgUrl.substring(imgUrl.lastIndexOf('.'));
|
|
|
result.state="SUCCESS";
|
|
|
}else{
|
|
|
result.state="FAIL";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return callback(null, result);
|
|
|
});
|
...
|
...
|
|