Created
October 2, 2018 20:07
-
-
Save camilomontoyau/6e2c41b4066cd458187a98e26d4094bb to your computer and use it in GitHub Desktop.
npm dropbox sdk example for nodejs file updload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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