I\'m trying to execute curl using node child_process to get a JSON file (about 220Ko) from a shared folder in a local network. But it actually returns a buffer problem that
You need to use and set the maxBuffer
option when using child_process.exec
. From the documentation:
maxBuffer
specifies the largest amount of data allowed on stdout or stderr - if this value is exceeded then the child process is killed.
The documentation also states that the default value of maxBuffer
is 200KB.
As an example, the maximum buffer size is increased to 500KB in the following code:
var execute = function(command, callback){
exec(command, {maxBuffer: 1024 * 500}, function(error, stdout, stderr){ callback(error, stdout); });
};
Additionally, you may want to read about http.get to see if it is capable of achieving what you are trying to do.