...
|
...
|
@@ -133,32 +133,39 @@ module.exports={ |
|
|
req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
|
|
req.body.bucket="goodsimg";
|
|
|
request.post({
|
|
|
url: config.domain + '/fileupload/upload',
|
|
|
url: "http://upload.static.yohobuy.com",
|
|
|
formData: {
|
|
|
fileData: req.body.files,
|
|
|
project: req.body.bucket
|
|
|
}
|
|
|
}, function optionalCallback(error, httpResponse, rebody) {
|
|
|
}, function optionalCallback(error, httpResponse, body) {
|
|
|
console.log(httpResponse.statusCode)
|
|
|
if (!error && httpResponse.statusCode == 200) {
|
|
|
console.log(2)
|
|
|
var ret = JSON.parse(body);
|
|
|
console.log(3);
|
|
|
if (ret.code === 200) {
|
|
|
console.log(4);
|
|
|
//var imgUrl = ret.data.imagesList[0];
|
|
|
var imgs = ret.data.imagesList || [];
|
|
|
var datas = [];
|
|
|
for (var i = 0; i < imgs.length; i++) {
|
|
|
datas.push(joinimg(imgs[i]))
|
|
|
}
|
|
|
|
|
|
var result={};
|
|
|
if(datas.length>0&&datas[0]){
|
|
|
// var imgs = ret.data.imagesList || [];
|
|
|
// var datas = [];
|
|
|
// for (var i = 0; i < imgs.length; i++) {
|
|
|
// datas.push(Utils.joinImg(imgs[i]))
|
|
|
// }
|
|
|
var imgUrl = ret.data.imagesList[0];
|
|
|
console.log(imgUrl);
|
|
|
result={};
|
|
|
if(imgUrl){
|
|
|
console.log(6);
|
|
|
result.originalName=Date.now();
|
|
|
result.name=Date.now();
|
|
|
result.url=datas[0];
|
|
|
result.type=datas[0].substring(datas[0].lastIndexOf('.'));
|
|
|
result.url=imgUrl;
|
|
|
result.type=imgUrl.substring(imgUrl.lastIndexOf('.'));
|
|
|
result.state="SUCCESS";
|
|
|
}else{
|
|
|
result.state="FAIL";
|
|
|
}
|
|
|
console.log(result);
|
|
|
}
|
|
|
}
|
|
|
return callback(null, result);
|
...
|
...
|
|