Documentation ¶
Index ¶
- Variables
- type AuthConfig
- type Config
- type DBConfig
- type LimitsConfig
- type Server
- func (s *Server) AddFile(contents io.Reader, contentType string, maxUses uint, storeUntil time.Time) (string, error)
- func (s *Server) Close() error
- func (s *Server) GetFile(fileUUID string) (r io.ReadSeeker, contentType string, err error)
- func (s *Server) OpenFile(fileUUID string) (io.ReadSeeker, error)
- func (s *Server) RemoveFile(fileUUID string) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
var ErrFileDoesntExists = errors.New("file doesn't exists")
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type Config ¶
type Config struct { // ListenOn specifies endpoint to listen on in format ADDR:PORT. Used only by filedropd. ListenOn string `yaml:"listen_on"` Limits LimitsConfig `yaml:"limits"` DB DBConfig `yaml:"db"` DownloadAuth AuthConfig `yaml:"download_auth"` UploadAuth AuthConfig `yaml:"upload_auth"` // StorageDir is where files will be saved on disk. StorageDir string `yaml:"storage_dir"` // HTTPSDownstream specifies whether filedrop should return links with https scheme or not. // Overridden by X-HTTPS-Downstream header. HTTPSDownstream bool `yaml:"https_downstream"` // AllowedOrigins specifies Access-Control-Allow-Origin header. AllowedOrigins string `yaml:"allowed_origins"` // Internal, used only for testing. Always 60 secs in production. CleanupIntervalSecs int `yaml:"-"` }
var Default Config
type LimitsConfig ¶
type LimitsConfig struct { // MaxUses is how much much times file can be accessed. Note that it also counts HEAD requests // and incomplete downloads (byte-range requests). // Per-file max-uses parameter can't exceed this value but can be smaller. MaxUses uint `yaml:"max_uses"` // MaxStoreSecs specifies max time for which files will be stored on // filedrop server. Per-file store-secs parameter can't exceed this value but // can be smaller. MaxStoreSecs uint `yaml:"max_store_secs"` // MaxFileSize is a maximum file size in bytes that can uploaded to filedrop. MaxFileSize uint `yaml:"max_file_size"` }
type Server ¶
type Server struct { DB *db Conf Config Logger *log.Logger DebugLogger *log.Logger // contains filtered or unexported fields }
Main filedrop server structure, implements http.Handler.
func New ¶
Create and initialize new server instance using passed configuration.
serv.Logger will be redirected to os.Stderr by default. Created instances should be closed by using serv.Close.
func (*Server) AddFile ¶
func (s *Server) AddFile(contents io.Reader, contentType string, maxUses uint, storeUntil time.Time) (string, error)
AddFile adds file to storage and returns assigned UUID which can be directly substituted into URL.
func (*Server) GetFile ¶
GetFile opens file for reading.
Note that access using this function is equivalent to access through HTTP API, so it will count against usage count, for example. To avoid this use OpenFile(fileUUID).
func (*Server) OpenFile ¶
func (s *Server) OpenFile(fileUUID string) (io.ReadSeeker, error)
OpenFile opens file for reading without any other side-effects applied (such as "link" usage counting).
func (*Server) RemoveFile ¶
RemoveFile removes file from database and underlying storage.