types

package
v0.0.0-...-b289748 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSHandler

func CORSHandler(req *http.Request, allowedOrigins []string, serve bool) (http.Header, int)

CORSHandler is the default preflight OPTIONS processor for use by media handlers.

func GetIdFromUrl

func GetIdFromUrl(url, serveUrl string) types.Uid

GetIdFromUrl is a helper method for extracting file ID from a URL.

Types

type Handler

type Handler interface {
	// Init initializes the media upload handler.
	Init(jsconf interface{}) error

	// Headers checks if the handler wants to provide additional HTTP headers for the request.
	//
	// It could be CORS headers, redirect to serve files from another URL, cache-control headers.
	//
	// It returns headers as a map, HTTP status code to stop processing or 0 to continue, error.
	Headers(req *http.Request, serve bool) (http.Header, int, error)

	// Upload processes request for file upload. Returns file URL, file size, error.
	Upload(fdef *types.FileDef, file io.ReadSeeker) (string, int64, error)

	// Download processes request for file download.
	Download(url string) (*types.FileDef, ReadSeekCloser, error)

	// Delete deletes file from storage.
	Delete(locations []string) error

	// GetIdFromUrl extracts file ID from download URL.
	GetIdFromUrl(url string) types.Uid
}

Handler is an interface which must be implemented by media handlers (uploaders-downloaders).

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

ReadSeekCloser must be implemented by the media being downloaded.

Jump to

Keyboard shortcuts

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