atm3-command-upload
Advanced tools
26
index.js
@@ -66,3 +66,3 @@ var Promise = require('bluebird'); | ||
receiver = conf.uploadService|| "http://wapstatic.kf0309.3g.qq.com/deploy", | ||
// receiver = conf.uploadService|| "http://localhost:8009/deploy", | ||
// receiver = conf.uploadService|| "http://localhost:8000/deploy", | ||
formData; | ||
@@ -80,3 +80,3 @@ if (!fr) { | ||
} | ||
fis.log.info("upload from:", fr, ", to:", to, ", ignore:", ignore); | ||
fis.log.info("upload from:", fr, ", to:", to, ", ignore:", ignore, ", receiver:", receiver); | ||
@@ -93,3 +93,3 @@ var dist = path.resolve(fr); | ||
formData = { | ||
to: path.join(to, relativePath), | ||
to: path.join(to, relativePath).replace(/\\/g, '/'), | ||
file: fs.createReadStream(file) | ||
@@ -99,6 +99,8 @@ }; | ||
request.post({ url: receiver, formData: formData }, function optionalCallback(err, httpResponse, body) { | ||
if (err) { | ||
return fis.log.error('upload failed:', relativePath + "\n Error:" + err); | ||
var code = httpResponse.statusCode; | ||
if(code == 200){ | ||
fis.log.info("Upload " + relativePath + " successful!"); | ||
}else{ | ||
return fis.log.error('code:', code, ' upload failed:', relativePath + "\nError:" + body); | ||
} | ||
fis.log.info("Upload " + relativePath + " successful!"); | ||
}); | ||
@@ -116,3 +118,3 @@ }); | ||
}else{ | ||
formData.to = path.join(formData.to, basename); | ||
formData.to = path.join(formData.to, basename).replace(/\\/g, '/'); | ||
} | ||
@@ -122,6 +124,8 @@ fis.log.info("formData: to", formData.to); | ||
request.post({ url: receiver, formData: formData }, function optionalCallback(err, httpResponse, body) { | ||
if (err) { | ||
return fis.log.error('upload failed:', dist + "\n Error:" + err); | ||
} | ||
fis.log.info("Upload successful!"); | ||
var code = httpResponse.statusCode; | ||
if(code == 200){ | ||
fis.log.info("Upload successful!"); | ||
}else{ | ||
return fis.log.error('code:', code, ' upload failed:', dist + "\nError:" + body); | ||
} | ||
}); | ||
@@ -128,0 +132,0 @@ } |
{ | ||
"name": "atm3-command-upload", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "the upload file command for atm3", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
8974
2.96%152
2.7%