uploader

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalUploader

type LocalUploader struct {
	Path string
	// contains filtered or unexported fields
}

LocalUploader saves files to a local directory.

func NewLocalUploader

func NewLocalUploader(path string, opts ...Option) *LocalUploader

NewLocalUploader creates a new LocalUploader.

func (*LocalUploader) Upload

func (u *LocalUploader) Upload(file multipart.File, filename string) (string, error)

Upload writes file into the uploader's directory and returns the saved path.

type Option

type Option func(*LocalUploader)

Option configures a LocalUploader.

func WithAllowedMime

func WithAllowedMime(mimes []string) Option

WithAllowedMime rejects uploads whose detected MIME type is not in the list.

func WithMaxSize

func WithMaxSize(bytes int64) Option

WithMaxSize rejects uploads larger than the given number of bytes.

type Uploader

type Uploader interface {
	Upload(file multipart.File, filename string) (string, error)
}

Uploader is an interface for uploading files.

Jump to

Keyboard shortcuts

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