Documentation
¶
Overview ¶
Methods dealing with files writing/reading from either the FS or a distant service (s3, ...) Copyright © 2015 - Rémy MATHIEU
Route giving the last uploaded files. Copyright © 2015 - Rémy MATHIEU
Saving information on the hosted files. Copyright © 2015 - Rémy MATHIEU
Route to search by tags Copyright © 2015 - Rémy MATHIEU
Route receiving the data when a file is uploaded. Copyright © 2015 - Rémy MATHIEU
Index ¶
- Constants
- func IsAuthValid(s *Server, r *http.Request) bool
- type AuthCheckHandler
- type CleanJob
- type Config
- type CorsHandler
- type DeleteHandler
- type FSConfig
- type Flags
- type LastUploadedHandler
- type LastUploadedResponse
- type Metadata
- type S3Config
- type SearchTagsEntryResponse
- type SearchTagsHandler
- type SearchTagsResponse
- type SendHandler
- type SendResponse
- type Server
- func (s *Server) Expire(m Metadata) error
- func (s *Server) GetEntry(id string) (*Metadata, error)
- func (s *Server) GetLastUploaded() ([]string, error)
- func (s *Server) ReadFile(filename string) ([]byte, error)
- func (s *Server) SetLastUploaded(lastUploaded []string) error
- func (s *Server) Start()
- func (s *Server) StartCleanJob()
- func (s *Server) WriteFile(filename string, data []byte) error
- type ServingHandler
Constants ¶
const ( FS_STORAGE = "fs" S3_STORAGE = "s3" )
const ( MAX_MEMORY = 1024 * 1024 DICTIONARY = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
const (
HEADER_ORIGINAL_FILENAME = "X-Upd-Orig-Filename"
)
const (
LAST_UPLOADED_KEY = "LastUploaded"
)
const (
MAX_LAST_UPLOADED = 20
)
const (
SECRET_KEY_HEADER = "X-upd-key"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthCheckHandler ¶
type AuthCheckHandler struct {
Server *Server // pointer to the started server
}
AuthCheckHandler simply tests whether the presented auth credentials are valid or not without doing any useless work
func (*AuthCheckHandler) ServeHTTP ¶
func (a *AuthCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Config ¶
type Config struct { Addr string `toml:"listen_addr"` // Address to listen to SecretKey string `toml:"secret_key"` // Secret between the client and the server RuntimeDir string `toml:"runtime_dir"` // Where the server can write the runtime files. Route string `toml:"route"` // Route served by the webserver CertificateFile string `toml:"certificate"` // Filepath to an tls certificate CertificateKey string `toml:"certificate_key"` // Filepath to the key part of a certificate Storage string `toml:"storage"` // possible values 'fs', 's3' FSConfig FSConfig `toml:"fsstorage"` S3Config S3Config `toml:"s3storage"` }
Server configuration
type CorsHandler ¶
type CorsHandler struct {
// contains filtered or unexported fields
}
CorsHandler adds the required CORS headers, and forwards the request to the real handler (with the notable exception of OPTIONS requests, that it will eat)
func (*CorsHandler) ServeHTTP ¶
func (c *CorsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DeleteHandler ¶
type DeleteHandler struct {
Server *Server // pointer to the started server
}
func (*DeleteHandler) ServeHTTP ¶
func (s *DeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Flags ¶
type Flags struct {
ConfigFile string // the file configuration to use for the server
}
Server flags
type LastUploadedHandler ¶
type LastUploadedHandler struct {
Server *Server // pointer to the started server
}
func (*LastUploadedHandler) ServeHTTP ¶
func (l *LastUploadedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type LastUploadedResponse ¶
type LastUploadedResponse struct { Name string `json:"name"` Original string `json:"original"` DeleteKey string `json:"delete_key"` CreationTime time.Time `json:"creation_time"` }
Json returned to the client
type Metadata ¶
type Metadata struct { Original string `json:"original"` // original name of the file. Filename string `json:"filename"` // name of the file on the FS Tags []string `json:"tags"` // tags attached to the uploaded file TTL string `json:"ttl"` // time.Duration representing the lifetime of the file. ExpirationTime time.Time `json:"expiration_time"` // at which time this file should expire. DeleteKey string `json:"delete_key"` // The key to delete this file. CreationTime time.Time `json:"creation_time"` }
type SearchTagsEntryResponse ¶
type SearchTagsEntryResponse struct { Filename string `json:"filename"` // name attributed by upd Original string `json:"original"` // original name of the file DeleteKey string `json:"delete_key"` // the delete key CreationTime time.Time `json:"creation_time"` // creation time of the given file ExpirationTime time.Time `json:"expiration_time"` // When this file expired Tags []string `json:"tags"` // Tags attached to this file. }
actually contains everything in Metadata but eh, looks more clean to do so if oneee daaay...
type SearchTagsHandler ¶
type SearchTagsHandler struct {
Server *Server // pointer to the started server
}
func (*SearchTagsHandler) ServeHTTP ¶
func (l *SearchTagsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SearchTagsResponse ¶
type SearchTagsResponse struct {
Results []SearchTagsEntryResponse `json:"results"`
}
Json returned to the client
type SendHandler ¶
type SendHandler struct {
Server *Server // pointer to the started server
}
func (*SendHandler) ServeHTTP ¶
func (s *SendHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SendResponse ¶
type SendResponse struct { Name string `json:"name"` DeleteKey string `json:"delete_key"` ExpirationTime time.Time `json:"expiration_time"` }
Json returned to the client
type Server ¶
type Server struct { Config Config // Configuration Database *bolt.DB // opened bolt db Storage string // Storage used with this metadata file. }
func (*Server) GetEntry ¶
getEntry looks in the Bolt DB whether this entry exists and returns it if found, otherwise, nil is returned.
func (*Server) GetLastUploaded ¶
GetLastUploaded reads into BoltDB the array of last uploaded entries.
func (*Server) ReadFile ¶
readFile is the method to read the file from wherever it is stored. The serverFlags are used to know where to read, the filename is used to know what to read.
func (*Server) SetLastUploaded ¶
type ServingHandler ¶
type ServingHandler struct {
Server *Server // pointer to the started server
}
func (*ServingHandler) ServeHTTP ¶
func (s *ServingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)