Skip to content

Instantly share code, notes, and snippets.

@mootoh
Created January 7, 2016 11:48
Show Gist options
  • Save mootoh/855e12dcdf7e8a9814fc to your computer and use it in GitHub Desktop.
Save mootoh/855e12dcdf7e8a9814fc to your computer and use it in GitHub Desktop.
'use strict';
let fs = require('fs')
, request = require('request')
;
let config = JSON.parse(fs.readFileSync('./config.json'));
let access_token = config.access_token;
let folder = config.folder;
let now = new Date();
let today = [now.getFullYear(), ('0' + (now.getMonth() + 1)).slice(-2), ('0' + (now.getDate())).slice(-2)].join('-');
let apiArg = {
"path": '/' + folder + '/' + today + '/slack.log',
"mode": "add",
"autorename": true,
"mute": false
};
request.post({
'url': 'https://content.dropboxapi.com/2/files/upload',
'headers': {
'Authorization': 'Bearer ' + access_token,
'Dropbox-API-Arg': JSON.stringify(apiArg),
'Content-Type': 'application/octet-stream'
},
'body': fs.readFileSync('./package.json')
}, function(error, response, body) {
console.log(error);
console.log(response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment