media

package
v0.0.0-...-8b94866 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MediaType_Value = map[string]int32{
	"MEDIA_TYPE_UNSPECIFIED": 0,
	"MEDIA_TYPE_UNKNOWN":     1,
	"TEXT":                   4,
	"IMAGE":                  5,
	"AUDIO":                  6,
	"VIDEO":                  7,
	"FILE":                   8,
}
View Source
var MediaType_name = map[int32]string{
	0: "MEDIA_TYPE_UNSPECIFIED",
	1: "MEDIA_TYPE_UNKNOWN",
	4: "TEXT",
	5: "IMAGE",
	6: "AUDIO",
	7: "VIDEO",
	8: "FILE",
}

Functions

func DetectExtension

func DetectExtension(buf []byte) string

func DetectMime

func DetectMime(stream io.Reader) (*mimetype.MIME, error)

func DetectType

func DetectType(buf []byte) string

func IsAllowedContentType

func IsAllowedContentType(contentType string, allowedContentType []string) bool

func ResizeImage

func ResizeImage(file io.Reader, contentType string, width, height uint) ([]byte, error)

func SetMimeReadLimit

func SetMimeReadLimit(n uint32)

Types

type MediaType

type MediaType int32
const (
	// The Default value
	MediaType_MEDIA_TYPE_UNSPECIFIED MediaType = 0
	// MediaType_MEDIA_TYPE_UNKNOWN Type is unknown. This is usually used when a process was unable to determine the type.
	MediaType_MEDIA_TYPE_UNKNOWN MediaType = 1
	MediaType_TEXT               MediaType = 4
	MediaType_IMAGE              MediaType = 5
	MediaType_AUDIO              MediaType = 6
	MediaType_VIDEO              MediaType = 7
	MediaType_FILE               MediaType = 8
)

func (MediaType) String

func (x MediaType) String() string

type MediaTypeInfo

type MediaTypeInfo interface {
	// MediaType returns the type of media for this info
	MediaType() MediaType

	// DirectoryName return a string which usually used to construct path for storing the media files
	DirectoryName() string

	// IsContentTypeAllowed returns true if the provided content type string is allowed for the media type
	IsContentTypeAllowed(contentType string) bool

	// MimeType returns mimetype.MIME wich is mimetype info of the document,
	// accept Reader as input, read whole file instead of partial byte of the Reader
	DetectReader(r io.Reader) (*mimetype.MIME, error)
}

func GetMediaTypeInfo

func GetMediaTypeInfo(mediaType MediaType) MediaTypeInfo

func GetMediaTypeInfoByTypeName

func GetMediaTypeInfoByTypeName(mediaTypeName string) MediaTypeInfo

type Reader

type Reader interface {
	io.Reader
	io.Seeker
	io.ReadSeeker
}

Directories

Path Synopsis
gcs
s3

Jump to

Keyboard shortcuts

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