Documentation ¶
Index ¶
- Constants
- func FileDelete(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FileGet(c *fiber.Ctx, cfg *cfg.Config, db *Db) error
- func FilePut(c *fiber.Ctx, cfg *cfg.Config, db *Db) (string, error)
- func IsExpired(start time.Time, duration string) bool
- func Log(format string, values ...any)
- func NormalizeFilename(file string) string
- func ProcessFormFiles(cfg *cfg.Config, members []string, id string) (string, string, error)
- func Runserver(cfg *cfg.Config, args []string) error
- func SaveFormFiles(c *fiber.Ctx, cfg *cfg.Config, files []*multipart.FileHeader, id string) ([]string, error)
- func SendResponse(c *fiber.Ctx, msg string, err error) error
- func Ts() string
- func Untaint(input string, wanted string) (string, error)
- func ZipDir(directory, zipfilename string) error
- type Db
- type Id
- type Meta
- type Result
- type Timestamp
- type Upload
Constants ¶
const ApiVersion string = "/v1"
const Bucket string = "uploads"
Variables ¶
This section is empty.
Functions ¶
func IsExpired ¶
Calculate if time is up based on start time.Time and duration. Returns true if time is expired. Start time comes from the database.
aka:
if(now - start) >= duration { time is up}
func NormalizeFilename ¶
func ProcessFormFiles ¶
generate return url. in case of multiple files, zip and remove them
func SaveFormFiles ¶
func SaveFormFiles(c *fiber.Ctx, cfg *cfg.Config, files []*multipart.FileHeader, id string) ([]string, error)
Extract form file[s] and store them on disk, returns a list of files
func SendResponse ¶
func Untaint ¶
Untaint user input, that is: remove all non supported chars.
wanted is a regexp matching chars we shall leave. Everything else will be removed. Eg:
untainted := Untaint(input, `[^a-zA-Z0-9\-]`)
Returns a new string and an error if the input string has been modified. It's the callers choice to decide what to do about it. You may ignore the error and use the untainted string or bail out.
Types ¶
type Meta ¶
type Meta struct {
Expire string `json:"expire" form:"expire"`
}
Binding from JSON, data coming from user, not tainted
type Timestamp ¶
Timestamp is like time.Time, but knows how to unmarshal from JSON Unix timestamp numbers or RFC3339 strings, and marshal back into the same JSON representation.
func (Timestamp) MarshalJSON ¶
func (*Timestamp) UnmarshalJSON ¶
type Upload ¶
type Upload struct { Id string `json:"id"` Expire string `json:"expire"` File string `json:"file"` // final filename (visible to the downloader) Members []string `json:"members"` // contains multiple files, so File is an archive Uploaded Timestamp `json:"uploaded"` }
stores 1 upload object, gets into db