Skip to content

Instantly share code, notes, and snippets.

@thisjt
Created July 1, 2023 07:23
Show Gist options
  • Save thisjt/4ae4c865f76fe74a985f48d1a13233f3 to your computer and use it in GitHub Desktop.
Save thisjt/4ae4c865f76fe74a985f48d1a13233f3 to your computer and use it in GitHub Desktop.
Function to Upload a (Zip) File to Dropbox
var Dropbox = require('dropbox').Dropbox
var accessToken = '##ACCESSTOKEN##'
var filename = 'fileToUpload.zip'
fs.readFile(filename, (err, data) => {
if(err) {
// handle error
return
}
(new Dropbox({ accessToken: accessToken })).filesUpload({
contents: data,
path: '/'+filename,
autorename: false,
}).then(response => {
// handle success
console.log(response)
}).catch(err => {
// handle error
console.log(err)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment