Skip to content

Commit d81f730

Browse files
author
Josh Cave
committed
filestorage
1 parent 9bfc4b5 commit d81f730

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

datastore.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Datastore struct {
4242
Settings Settings
4343
Websocket Websocket
4444
Logger Logger
45+
FileStorage FileStorage
4546
}
4647

4748
type Settings interface {
@@ -74,6 +75,14 @@ func (ds *Datastore) TurnOffLogging() {
7475
dat.SetErrorLogger(nil)
7576
}
7677

78+
type FileStorage interface {
79+
OpenFile(fileIdentifier string) (b []byte, fileIdentifier string, fullURL string, err error)
80+
GetURL(fileIdentifier string) (fullURL string)
81+
// always returning bytes might be a little expensive, but it makes the interface much more reasonable
82+
SaveFile(fileIdentifier string, b io.Reader) (fileIdentifier string, fullURL string, err error)
83+
}
84+
85+
7786
// type Logger struct {
7887
// errLog string
7988
// }
@@ -117,12 +126,13 @@ func (ds *Datastore) TurnOffLogging() {
117126

118127
// New - returns a new datastore which contains redis, database and settings.
119128
// everything in the datastore should be concurrent safe and stand within thier own right. i.e. accessible at anypoint from the app
120-
func New(logger Logger, settings Settings, cache Cache, ws Websocket) *Datastore {
129+
func New(logger Logger, settings Settings, cache Cache, filestorage FileStorage, ws Websocket) *Datastore {
121130
store := Simple()
122131
store.Logger = logger
123132
store.Settings = settings
124133
store.DB = getDBConnection(store, cache)
125134
store.Cache = cache
135+
store.FileStorage =
126136
return store
127137
}
128138

0 commit comments

Comments
 (0)