This is my code:
var _reqOptions = {
method: _setMethod(_me.action),
headers: _getHeaders(_me.actionString),
url: "https://" + parent.url + "/" + parent.cpCode + path
};
var _request = request(_reqOptions, function(err, res, body) {
console.log(body);
(new xml2js.Parser())
.parseString(body, function (err, result) {
if (err) {
return _promise.resolve([err]);
}
var xml = _.merge({}, result, function (a, b) {
var obj = {};
if (b instanceof Object) {
Object.keys(b).forEach(function (key) {
if (key === '$') {
obj.attribs = b[key];
} else if (_.isArray(b[key])) {
obj[key] = _.pluck(b[key], '$');
}
});
} else {
obj[0] = b;
}
return obj;
});
return _promise.resolve([null, xml]);
});
});
console.log("Request initiated");
_request.on("error", function(err) {
console.log("Error!", err);
})
if (this.data) {
console.log("Sending data");
_request.write(this.data, function() {
console.log("writed");
_me.data = null;
_request.end();
});
} else {
_request.end();
}
console.log("Process to sent data initiated");
And the debug is:
Starting process to upload file /cuw/Uq8rXzH6ppZKIyHMu6ftmilTyGyM8sehu3HRiWS3_1_cuw.mp4
REQUEST { url: 'http://ift.tt/1Nr2JLs',
headers:
{ Host: 'abc-nsu.akamaihd.net',
'X-Akamai-ACS-Action': 'version=1&action=upload',
'X-Akamai-ACS-Auth-Data': '5, 0.0.0.0, 0.0.0.0, 1425672014, 959394462, keyname',
'X-Akamai-ACS-Auth-Sign': 'Al5PdVblbn676ShkXAL1RJXg9ZER5JgnvhqNwGxiR5A=' },
method: 'put',
callback: [Function],
uri: undefined }
Request initiated
Sending data
REQUEST make request http://ift.tt/1Nr2JLs
Process to sent data initiated
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
The problem I have is for some reason with this specific file:
125025 -rw-r--r-- 1 root root 191.0M Mar 6 20:00 index_650_av-p.mp4
It breaks, while with other it works ok...
I've try to find a solution but there are other modules in node that throws this error, but nothing I've found is related with request module.
You can see from the code and the log, the process tries to execute this: _request.write(this.data, function() { but that is when it fails...
Aucun commentaire:
Enregistrer un commentaire