-
Notifications
You must be signed in to change notification settings - Fork 2
/
file.go
36 lines (30 loc) · 844 Bytes
/
file.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
package storage
import "io"
// IFILE factory pattern interface
type IFILE interface {
List(pageSize int64, pageToken ...string) (interface{}, error)
GetMetaData(fileID string) (interface{}, error)
CreateFolder(name string, parents ...string) (interface{}, error)
Upload(name string, fileContent io.Reader, parents ...string) (interface{}, error)
Download(fileID string) (interface{}, error)
Move(fileID, oldParentID, newParentID string) (interface{}, error)
Delete(fileIDs []string) error
}
const (
// DRIVE cloud services
DRIVE = iota
// CUSTOMFILE file services
CUSTOMFILE
)
// newFile Factory Pattern
func newFile(
databaseCompany int,
config *Config) interface{} {
switch databaseCompany {
case DRIVE:
return newDrive(&config.GoogleDrive)
case CUSTOMFILE:
return newCustomFile(&config.CustomFile)
}
return nil
}