cdn

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFileSize int64 = 10 << 20
	MaxMemSize        = 10 << 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CDN

type CDN struct {
	HTTP *http.Client
	URL  string
}

func (CDN) Download

func (cdn CDN) Download(name string) (io.Reader, error)

Download a file from the CDN.

func (CDN) Upload

func (cdn CDN) Upload(name string, file io.Reader) error

Upload a file to the CDN.

type Downloader

type Downloader interface {
	Download(name string) (io.Reader, error)
}

A Downloader retrieves a file by name.

type HTTP

type HTTP struct {
	EntClient *ent.Client
}

HTTP handlers for file upload & download.

func (HTTP) HandleFileDownload

func (h HTTP) HandleFileDownload(w http.ResponseWriter, r *http.Request)

HandleFileDownload is an http.HandlerFunc which loads a file by name and serves it's content.

func (HTTP) HandleFileUpload

func (h HTTP) HandleFileUpload(w http.ResponseWriter, r *http.Request)

HandleFileUpload is an http.HandlerFunc which parses multipart forms and upserts file objects.

func (h HTTP) HandleLink(w http.ResponseWriter, r *http.Request)

HandleLink is an http.HandlerFunc which loads a file by its link and serves it's content.

type Uploader

type Uploader interface {
	Upload(name string, file io.Reader) error
}

An Uploader saves files by name. It is responsible for closing the file after writing if the file implements io.Closer.

Jump to

Keyboard shortcuts

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