types

package
v0.0.0-...-5e8511f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMime = errors.New("Invalid mime")
View Source
var ErrSkip = errors.New("Skip")

Functions

func RegisterMimeProvider

func RegisterMimeProvider(name string, provider MimeTypeProvider)

func RegisterProvider

func RegisterProvider(name string, provider FileInfoProvider)

Types

type FileInfoProvider

type FileInfoProvider interface {
	// indicate how many bytes you need at minimum to be able to determine
	// your specific file info. you won't get more than provided. in case you
	// need all the data, please return -1. In case the provided mime type doesn't
	// suit you and you know you won't be able to do anything with the data, returning
	// any error from here will skip the provider
	MinimumBytes(typ, subtyp string) (int64, error)

	Check(filename string, reader io.Reader) ([]byte, error)
	Render(data []byte) (string, string, error)
}

func GetProvider

func GetProvider(name string) (FileInfoProvider, error)

type MimeType

type MimeType struct {
	Type    string `json:"type"`
	SubType string `json:"subtype"`
}

func ParseMime

func ParseMime(in string) (MimeType, error)

func (MimeType) Match

func (m MimeType) Match(pattern string) bool

func (MimeType) String

func (m MimeType) String() string

type MimeTypeProvider

type MimeTypeProvider interface {
	Init() error
	io.Closer

	MinimumBytes() int64

	MimeType(filename string, reader io.Reader) (*MimeType, error)
}

func GetMimeProvider

func GetMimeProvider(name string) (MimeTypeProvider, error)

type Result

type Result struct {
	Name  string `json:"name"`
	Data  []byte `json:"data"`
	Human string `json:"human"`
	Title string `json:"title"`
	Err   error  `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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