Documentation ¶
Overview ¶
Package media defines an interface which must be implemented by media upload/download handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORSHandler ¶ added in v0.17.6
CORSHandler is the default CORS processor for use by media handlers. It adds CORS headers to preflight OPTIONS requests, Vary & Access-Control-Allow-Origin headers to all responses.
func GetIdFromUrl ¶ added in v0.15.7
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 string) 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).
Directories ¶
Path | Synopsis |
---|---|
Package fs implements github.com/tinode/chat/server/media interface by storing media objects in a single directory in the file system.
|
Package fs implements github.com/tinode/chat/server/media interface by storing media objects in a single directory in the file system. |
Package s3 implements media interface by storing media objects in Amazon S3 bucket.
|
Package s3 implements media interface by storing media objects in Amazon S3 bucket. |
Click to show internal directories.
Click to hide internal directories.