-
Notifications
You must be signed in to change notification settings - Fork 351
/
index.js
33 lines (33 loc) · 1.12 KB
/
index.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
Object.defineProperty(exports, "__esModule", { value: true });
const dropbox_1 = require("dropbox"); // eslint-disable-line no-unused-vars
const fs = require("fs");
const prompt = require('prompt');
prompt.start();
prompt.get({
properties: {
accessToken: {
description: 'Please enter an API V2 access token',
},
sharedLink: {
description: 'Please enter a shared link to a file',
},
},
}, (error, result) => {
const dbx = new dropbox_1.Dropbox({ accessToken: result.accessToken });
dbx.sharingGetSharedLinkFile({ url: result.sharedLink })
.then((data) => {
// Note: The fileBinary field is not part of the Dropbox SDK
// specification, so it is not included in the TypeScript type.
// It is injected by the SDK.
fs.writeFile(data.result.name, data.result.fileBinary, { encoding: 'binary' }, (err) => {
if (err) {
throw err;
}
console.log(`File: ${data.result.name} saved.`);
});
})
.catch((err) => {
throw err;
});
});
//# sourceMappingURL=download.js.map