forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropboxjs-tests.ts
54 lines (41 loc) · 1.55 KB
/
dropboxjs-tests.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/// <reference path="dropboxjs.d.ts" />
var browserClient = new Dropbox.Client({ key: "your-key-here" });
browserClient.authenticate((error:any, client:Dropbox.Client) => {
if (error) {
alert(error);
}
client.onError.addListener((error:any) =>{
if (window['console']) { // Skip the "if" in node.js code.
console.error(error);
}
});
client.getAccountInfo( (error:Dropbox.ApiError, accountInfo:Dropbox.AccountInfo) => {
if (error) {
alert(error); // Something went wrong.
}
alert("Hello, " + accountInfo.name + "!");
});
client.writeFile("hello_world.txt", "Hello, world!\n", (error:Dropbox.ApiError, stat:Dropbox.File.Stat ) => {
if (error) {
alert(error); // Something went wrong.
}
alert("File saved as revision " + stat.versionTag);
});
client.readFile("hello_world.txt", (error:Dropbox.ApiError, data:string) => {
if (error) {
alert(error); // Something went wrong.
}
alert(data); // data has the file's contents
});
client.readdir("/", (err: Dropbox.ApiError, filenames: string[], stat: Dropbox.File.Stat, folderEntries: Dropbox.File.Stat[]) => {
if (error) {
alert(error); // Something went wrong.
}
alert("Your Dropbox contains " + filenames.join(", "));
});
});
var serverClient = new Dropbox.Client({
key: "your-key-here",
secret: "your-secret-here"
});
serverClient.authDriver(new Dropbox.AuthDriver.NodeServer({port:8191}));