Files
DefinitelyTyped/dropboxjs/dropboxjs-tests.ts
Steve Fenton b1776d0257 Dropbox-JS Definition.
The dropbox-js project is a wrapped for the Dropbox API.
2014-07-23 23:00:11 +01:00

54 lines
1.4 KiB
TypeScript

/// <reference path="dropboxjs.d.ts" />
var browserClient = new Dropbox.Client({ key: "your-key-here" });
browserClient.authenticate(function (error, client) {
if (error) {
alert(error);
}
client.onError.addListener(function (error) {
if (window.console) { // Skip the "if" in node.js code.
console.error(error);
}
});
client.getAccountInfo(function (error, accountInfo) {
if (error) {
alert(error); // Something went wrong.
}
alert("Hello, " + accountInfo.name + "!");
});
client.writeFile("hello_world.txt", "Hello, world!\n", function (error, stat) {
if (error) {
alert(error); // Something went wrong.
}
alert("File saved as revision " + stat.versionTag);
});
client.readFile("hello_world.txt", function (error, data) {
if (error) {
alert(error); // Something went wrong.
}
alert(data); // data has the file's contents
});
client.readdir("/", function (error, entries) {
if (error) {
alert(error); // Something went wrong.
}
alert("Your Dropbox contains " + entries.join(", "));
});
});
var serverClient = new Dropbox.Client({
key: "your-key-here",
secret: "your-secret-here"
});
serverClient.authDriver(new Dropbox.AuthDriver.NodeServer(8191));