Skip to content

Instantly share code, notes, and snippets.

@camilomontoyau
Created October 2, 2018 20:07
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/6e2c41b4066cd458187a98e26d4094bb to your computer and use it in GitHub Desktop.
Save camilomontoyau/6e2c41b4066cd458187a98e26d4094bb to your computer and use it in GitHub Desktop.
npm dropbox sdk example for nodejs file updload
const { Dropbox } = require('dropbox');
const fs = require('fs');
const path = require('path');
const fetch = require('isomorphic-fetch');
const {DROPBOX_AUTH} = process.env
var dbx = new Dropbox({ accessToken: DROPBOX_AUTH, fetch });
fs.readFile(path.join(__dirname, '/test.txt'), 'utf8', function(err, contents) {
if (err) {
console.log('Error: ', err);
}
// This uploads basic.js to the root of your dropbox
dbx
.filesUpload({ path: '/test.txt', contents })
.then(function(response) {
console.log('response', response);
})
.catch(function(err) {
console.log('err', err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment