2020-02-24 18:07:47 +00:00
|
|
|
package files
|
|
|
|
|
2020-03-19 10:13:38 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
2020-02-24 18:07:47 +00:00
|
|
|
|
|
|
|
type FileProvider struct {
|
2020-03-15 23:48:37 +00:00
|
|
|
Name string `yaml:"name"`
|
|
|
|
Provider string `yaml:"provider"`
|
|
|
|
Authentication string `yaml:"authentication"`
|
|
|
|
Location string `yaml:"path"`
|
|
|
|
Config map[string]string `yaml:"config"`
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Directory struct {
|
2020-03-15 23:48:37 +00:00
|
|
|
Path string
|
|
|
|
Files []FileInfo
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type FileInfo struct {
|
|
|
|
IsDirectory bool
|
|
|
|
Name string
|
|
|
|
Extension string
|
|
|
|
}
|
|
|
|
|
2020-03-15 23:48:37 +00:00
|
|
|
type FileContents struct {
|
|
|
|
Content []byte
|
|
|
|
IsUrl bool
|
|
|
|
}
|
|
|
|
|
2020-02-24 18:07:47 +00:00
|
|
|
type FileProviderInterface interface {
|
2020-03-21 00:31:24 +00:00
|
|
|
Setup(args map[string]string) bool
|
2020-02-24 18:07:47 +00:00
|
|
|
GetDirectory(path string) Directory
|
2020-04-15 12:16:27 +01:00
|
|
|
ViewFile(path string) string
|
|
|
|
RemoteFile(path string, writer io.Writer)
|
2020-04-03 13:26:06 +01:00
|
|
|
SaveFile(file io.Reader, filename string, path string) bool
|
2020-04-15 12:16:27 +01:00
|
|
|
ObjectInfo(path string) (string, string)
|
2020-04-12 22:10:51 +01:00
|
|
|
CreateDirectory(path string) bool
|
|
|
|
Delete(path string) bool
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 00:31:24 +00:00
|
|
|
/** DO NOT USE THESE DEFAULTS **/
|
|
|
|
func (f FileProvider) Setup(args map[string]string) bool {
|
|
|
|
return false
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f FileProvider) GetDirectory(path string) Directory {
|
|
|
|
return Directory{}
|
|
|
|
}
|
|
|
|
|
2020-04-15 12:16:27 +01:00
|
|
|
func (f FileProvider) ViewFile(path string) string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f FileProvider) RemoteFile(path string, writer io.Writer) {
|
2020-03-19 10:13:38 +00:00
|
|
|
return
|
2020-02-24 18:07:47 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 13:26:06 +01:00
|
|
|
func (f FileProvider) SaveFile(file io.Reader, filename string, path string) bool {
|
2020-02-24 18:07:47 +00:00
|
|
|
return false
|
2020-03-15 23:48:37 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 12:16:27 +01:00
|
|
|
func (f FileProvider) ObjectInfo(path string) (string, string) {
|
|
|
|
return "", ""
|
2020-03-15 23:48:37 +00:00
|
|
|
}
|
2020-03-21 00:31:24 +00:00
|
|
|
|
2020-04-12 22:10:51 +01:00
|
|
|
func (f FileProvider) CreateDirectory(path string) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f FileProvider) Delete(path string) bool {
|
|
|
|
return false
|
2020-04-15 12:16:27 +01:00
|
|
|
}
|