sintaxi / dbox

NodeJS SDK for Dropbox API (THIS LIBRARY IS OBSOLETE!!)
514 stars 91 forks source link

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

Open faressoft opened 8 years ago

faressoft commented 8 years ago

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');

});