forked from echoiie/genshin-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropbox.js
34 lines (31 loc) · 1.08 KB
/
dropbox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('dotenv').config();
const fs = require('fs');
const path = require('path');
const https = require("https");
const tmpFolder = './tmp';
fs.readdir(tmpFolder, (err, files) => {
fs.readFile(path.join('tmp', files[0]), function (err, data) {
const req = https.request('https://content.dropboxapi.com/2/files/upload', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.DROPBOX_TOKEN}`,
'Dropbox-API-Arg': JSON.stringify({
'path': `/${files[0]}`,
'mode': 'overwrite',
'autorename': true,
'mute': false,
'strict_conflict': false
}),
'Content-Type': 'application/octet-stream',
}
}, (res) => {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
req.write(data);
req.end();
});
});