mirror of
https://github.com/gmemstr/sliproad.git
synced 2024-09-20 00:21:15 +01:00
c28851fcc3
Making some improvements to the future maintainability of the project, namely in the form of tests. Also implemented a new "dist" command to the Makefile that packs up the binaries, and will eventually be expanded to do more legwork when prepping for a release. Updated file providers to use io.Reader over an explicit multipart file, and removed the handler in favour of a plain filename, since that was it's primary purpose.
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package files
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
type FileProvider struct {
|
|
Name string `yaml:"name"`
|
|
Provider string `yaml:"provider"`
|
|
Authentication string `yaml:"authentication"`
|
|
Location string `yaml:"path"`
|
|
Config map[string]string `yaml:"config"`
|
|
}
|
|
|
|
type Directory struct {
|
|
Path string
|
|
Files []FileInfo
|
|
}
|
|
|
|
type FileInfo struct {
|
|
IsDirectory bool
|
|
Name string
|
|
Extension string
|
|
}
|
|
|
|
type FileContents struct {
|
|
Content []byte
|
|
IsUrl bool
|
|
}
|
|
|
|
type FileProviderInterface interface {
|
|
Setup(args map[string]string) bool
|
|
GetDirectory(path string) Directory
|
|
ViewFile(path string, w io.Writer)
|
|
SaveFile(file io.Reader, filename string, path string) bool
|
|
DetermineType(path string) string
|
|
}
|
|
|
|
/** DO NOT USE THESE DEFAULTS **/
|
|
func (f FileProvider) Setup(args map[string]string) bool {
|
|
return false
|
|
}
|
|
|
|
func (f FileProvider) GetDirectory(path string) Directory {
|
|
return Directory{}
|
|
}
|
|
|
|
func (f FileProvider) ViewFile(path string, w io.Writer) {
|
|
return
|
|
}
|
|
|
|
func (f FileProvider) SaveFile(file io.Reader, filename string, path string) bool {
|
|
return false
|
|
}
|
|
|
|
func (f FileProvider) DetermineType(path string) string {
|
|
return ""
|
|
}
|
|
|