|
@@ -133,32 +133,39 @@ module.exports={ |
|
@@ -133,32 +133,39 @@ module.exports={ |
133
|
req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
133
|
req.body.files = [fs.createReadStream(req.files.upfile.path)];
|
134
|
req.body.bucket="goodsimg";
|
134
|
req.body.bucket="goodsimg";
|
135
|
request.post({
|
135
|
request.post({
|
136
|
- url: config.domain + '/fileupload/upload',
|
136
|
+ url: "http://upload.static.yohobuy.com",
|
137
|
formData: {
|
137
|
formData: {
|
138
|
fileData: req.body.files,
|
138
|
fileData: req.body.files,
|
139
|
project: req.body.bucket
|
139
|
project: req.body.bucket
|
140
|
}
|
140
|
}
|
141
|
- }, function optionalCallback(error, httpResponse, rebody) {
|
141
|
+ }, function optionalCallback(error, httpResponse, body) {
|
|
|
142
|
+ console.log(httpResponse.statusCode)
|
142
|
if (!error && httpResponse.statusCode == 200) {
|
143
|
if (!error && httpResponse.statusCode == 200) {
|
|
|
144
|
+ console.log(2)
|
143
|
var ret = JSON.parse(body);
|
145
|
var ret = JSON.parse(body);
|
|
|
146
|
+ console.log(3);
|
144
|
if (ret.code === 200) {
|
147
|
if (ret.code === 200) {
|
|
|
148
|
+ console.log(4);
|
145
|
//var imgUrl = ret.data.imagesList[0];
|
149
|
//var imgUrl = ret.data.imagesList[0];
|
146
|
- var imgs = ret.data.imagesList || [];
|
|
|
147
|
- var datas = [];
|
|
|
148
|
- for (var i = 0; i < imgs.length; i++) {
|
|
|
149
|
- datas.push(joinimg(imgs[i]))
|
|
|
150
|
- }
|
|
|
151
|
-
|
|
|
152
|
- var result={};
|
|
|
153
|
- if(datas.length>0&&datas[0]){
|
150
|
+ // var imgs = ret.data.imagesList || [];
|
|
|
151
|
+ // var datas = [];
|
|
|
152
|
+ // for (var i = 0; i < imgs.length; i++) {
|
|
|
153
|
+ // datas.push(Utils.joinImg(imgs[i]))
|
|
|
154
|
+ // }
|
|
|
155
|
+ var imgUrl = ret.data.imagesList[0];
|
|
|
156
|
+ console.log(imgUrl);
|
|
|
157
|
+ result={};
|
|
|
158
|
+ if(imgUrl){
|
|
|
159
|
+ console.log(6);
|
154
|
result.originalName=Date.now();
|
160
|
result.originalName=Date.now();
|
155
|
result.name=Date.now();
|
161
|
result.name=Date.now();
|
156
|
- result.url=datas[0];
|
|
|
157
|
- result.type=datas[0].substring(datas[0].lastIndexOf('.'));
|
162
|
+ result.url=imgUrl;
|
|
|
163
|
+ result.type=imgUrl.substring(imgUrl.lastIndexOf('.'));
|
158
|
result.state="SUCCESS";
|
164
|
result.state="SUCCESS";
|
159
|
}else{
|
165
|
}else{
|
160
|
result.state="FAIL";
|
166
|
result.state="FAIL";
|
161
|
}
|
167
|
}
|
|
|
168
|
+ console.log(result);
|
162
|
}
|
169
|
}
|
163
|
}
|
170
|
}
|
164
|
return callback(null, result);
|
171
|
return callback(null, result);
|