-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.application.go
75 lines (64 loc) · 1.82 KB
/
sample.application.go
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"fmt"
"github.com/markdicksonjr/nibbler"
"github.com/markdicksonjr/nibbler/storage/google/drive"
"log"
)
func main() {
// allocate logger and configuration
var logger nibbler.Logger = nibbler.DefaultLogger{}
// allocate configuration (from env vars, files, etc)
config, err := nibbler.LoadConfiguration(nil)
if err != nil {
log.Fatal(err)
}
// allocate the S3 extension
driveExtension := drive.Extension{}
// prepare extensions for initialization
extensions := []nibbler.Extension{
&driveExtension,
}
// create and initialize the application
app := nibbler.Application{}
if err = app.Init(config, &logger, &extensions); err != nil {
log.Fatal(err.Error())
}
// initialize the drive extension's service separately.
// this step can be combined with .Init by creating the
// extension with ConnectServiceOnInit = true
if err = driveExtension.InitService(); err != nil {
log.Fatal(err.Error())
}
r, err := driveExtension.Srv.Files.List().PageSize(25).
Fields("nextPageToken, files(id, name, md5Checksum, mimeType, parents)").Do()
if err != nil {
log.Fatalf("Unable to retrieve files: %v", err)
}
fmt.Println("Files/Folders:")
if len(r.Files) == 0 {
fmt.Println("No files found.")
} else {
for _, i := range r.Files {
if i.MimeType == "application/vnd.google-apps.folder" {
fmt.Printf("Folder: %s [%s] (%s)\n", i.Name, i.MimeType, i.Id)
} else {
fmt.Printf("File: %s [%s] (%s) md5:%s\n", i.Name, i.MimeType, i.Id, i.Md5Checksum)
}
}
}
//
//// print buckets to the console, with creation time
//fmt.Println("Buckets:")
//for _, b := range result.Buckets {
// fmt.Printf("* %s created on %s\n",
// aws.StringValue(b.Name), aws.TimeValue(b.CreationDate))
//}
//
//// start the app
//err = app.Run()
//
//if err != nil {
// log.Fatal(err.Error())
//}
}