Created
January 7, 2016 11:48
-
-
Save mootoh/855e12dcdf7e8a9814fc to your computer and use it in GitHub Desktop.
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
'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