sliproad/files/fileprovider.go
Gabriel Simmer e1b8c50d55
Delete files and create directories.
Added DELETE handler to files endpoint for deleting files and
directories, along with new handling for creating directories, as
specified with the `X-NAS-Type` header - if this is set to "directory",
a new directory is created with the path of the request. Otherwise, an
attempt to parse the file from form data is done as before.

Also added buttons to interact with the new functionality in the default
frontend.
2020-04-12 22:10:51 +01:00

70 lines
1.4 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
CreateDirectory(path string) bool
Delete(path string) bool
}
/** 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 ""
}
func (f FileProvider) CreateDirectory(path string) bool {
return false
}
func (f FileProvider) Delete(path string) bool {
return false
}