dbox icon indicating copy to clipboard operation
dbox copied to clipboard

Add the ability to upload a file by passing a readable stream

Open faressoft opened this issue 9 years ago • 0 comments

It is not a good idea to upload files using buffers that must be loaded into the memory before they can be passed to the .put() method to upload them, especially with very large files which exceeds the memory size.

So, I have added the ability to the .put() method to receive either a buffer(or string) or a readable stream without breaking the .put() api, so my changes is compatible with any previous usage of the method.

client.put(remoteFilePath, fs.createReadStream(localFilePath), function(status, reply) {

  if (status !== 200) {
    return exit('Uplading is failed');
  }

  exit('Done');

});

faressoft avatar Jun 08 '16 19:06 faressoft