-
Notifications
You must be signed in to change notification settings - Fork 1
/
fm_file_constructor.go
72 lines (57 loc) · 1.84 KB
/
fm_file_constructor.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
package gofm
import (
"github.com/99designs/gqlgen/graphql"
"gorm.io/gorm"
)
type NewFile struct {
// InputFile -> should be indicated, other params are optional!
InputFilePath string
GraphQLFile *graphql.Upload
// FileModel - asta e modelul din partea la client...
FileModel interface{}
// TODO : add here other methods of input like:
// - bytes
// - io
//======= Optional ======= \\
// Name -> can
// TODO: parametrii acestia pot fi scosi.. pentru ca ei pot fi scrisi insasi in Model
//Name string
//Description string
//CategoryID *uuid.UUID
//// Extension -> is needed only when a physical file is not provided, but a Bytes input has been provided
//Extension string
//======= Optional ======= \\
// ========= Helpers =========\\
// by indicating InputFile, it will be read from there
// TODO: should we add here the locations where to be saved...
fileManager *FileManager
// ========= Helpers =========\\
//
// ========= Locations ==========\\
//Locations Locations
Locations []NewFileLocation
// ========= Locations ==========\\
}
type NewFileLocation struct {
// this is the instance name
LocationName string
// add other options...
// if none of the lower params are indicated, it will take the current files basedir and it will
// recreate on the destination location
//========= Optional Params ===========\\
// DirPath -> is optional, a new folder path is indicated, the file name remains the same!
DirPath string
// FilePath -> is optional, a new full file path is indicated (it includes as the dir path)
FilePath string
//========= Optional Params ===========\\
}
// NewFile -> create a new file in the DB
func (fm *FileManager) NewFile() *NewFile {
return &NewFile{
// Set the file manager as reference
fileManager: fm,
}
}
func (f *NewFile) db() *gorm.DB {
return f.fileManager.DB()
}