upload

package
v0.0.0-...-8577a5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFiles = 128

Variables

View Source
var ErrTooManyFiles = httperr.New(400, "too many files; max 128")

Functions

This section is empty.

Types

type ErrUnsupportedType

type ErrUnsupportedType struct {
	ContentType string
}

func (ErrUnsupportedType) Error

func (err ErrUnsupportedType) Error() string

func (ErrUnsupportedType) StatusCode

func (err ErrUnsupportedType) StatusCode() int

type MaxSize

type MaxSize struct {
	// contains filtered or unexported fields
}

MaxSize contains a list of size overrides. A zero-value instance is a valid instance.

func (MaxSize) SizeLimit

func (c MaxSize) SizeLimit(ctype string) (bytes datasize.ByteSize)

func (*MaxSize) UnmarshalTOML

func (c *MaxSize) UnmarshalTOML(v interface{}) error

type UploadConfig

type UploadConfig struct {
	FileDirectory string            `toml:"fileDirectory"`
	MaxFileSize   datasize.ByteSize `toml:"maxFileSize"`
	AllowedTypes  []string          `toml:"allowedTypes"`
	MaxSize       MaxSize
}

func NewConfig

func NewConfig() UploadConfig

func (UploadConfig) CleanupPost

func (c UploadConfig) CleanupPost(post smolboard.Post)

CleanupPost cleans up a single post asynchronously.

func (UploadConfig) CleanupPosts

func (c UploadConfig) CleanupPosts(posts []*smolboard.Post)

CleanupPosts cleans up posts asynchronously.

func (UploadConfig) ContentTypeAllowed

func (c UploadConfig) ContentTypeAllowed(ctype string) bool

func (UploadConfig) CreatePosts

func (c UploadConfig) CreatePosts(headers []*multipart.FileHeader) ([]*smolboard.Post, error)

func (*UploadConfig) Validate

func (c *UploadConfig) Validate() error

func (UploadConfig) WrapReader

func (c UploadConfig) WrapReader(r io.Reader) (*limread.LimitedReader, error)

WrapReader wraps the given reader and restrict its MIME type as well as file size.

Directories

Path Synopsis
Package atomdl provides helper functions to allow atomic file downloads.
Package atomdl provides helper functions to allow atomic file downloads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL