-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogledrive-test.js
37 lines (32 loc) · 1.07 KB
/
googledrive-test.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
35
36
37
var gdrive = require("./googledrive");
var cb = function (callback) {
return function (err, response) {
if (err) {
console.log("[ERROR] " + (err.responseText || ""));
console.log(err);
} else {
console.log("[Success]");
console.log(response);
callback(err, response);
}
};
};
var CLIENT_ID = process.env.CLIENT_ID;
var CLIENT_SECRET = process.env.CLIENT_SECRET;
var info = {
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
redirectUrl: "http://localhost:3000/",
};
gdrive.getClient(info, function (client) {
client.createFolder("Test Folder", cb(function (err, result) {
client.uploadOfficeFile("sample.docx", cb(function (err, result) {
client.searchFile({ title: "sample" }, cb(function (err, result) {
client.getFile(result.id, cb(function (err, result) {
client.downloadFile(result, "download.docx", cb(function (err, result) {
}));
}));
}));
}));
}));
});