Skip to content

Instantly share code, notes, and snippets.

@camilomontoyau
Created October 2, 2018 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camilomontoyau/944502e2144a20fd5e2c6996c4d3382b to your computer and use it in GitHub Desktop.
Save camilomontoyau/944502e2144a20fd5e2c6996c4d3382b to your computer and use it in GitHub Desktop.
npm dropbox upload files via streams
const dropboxV2Api = require('dropbox-v2-api');
const path = require('path');
const fs = require('fs');
const {token} = process.env;
const dropbox = dropboxV2Api.authenticate({
token
});
const dropboxUploadStream = dropbox(
{
resource: 'files/upload',
parameters: {
path: '/test2.txt'
}
},
(err, result, response) => {
if (err) console.log({ err });
if (result) console.log({ result });
if (response) console.log({ response });
}
);
fs.createReadStream(path.join(__dirname, '/test.txt')).pipe(
dropboxUploadStream
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment