media

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ImageTypeJPEG JPEG format
	ImageTypeJPEG string = "image/jpeg"

	// ImageTypePNG PNG format
	ImageTypePNG string = "image/png"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Generic

type Generic struct {
	// contains filtered or unexported fields
}

Generic holds binary data defined by its MIME type.

func NewGeneric

func NewGeneric(mime string, data []byte) Generic

NewGeneric creates a new Generic object.

func (Generic) Base64URL

func (g Generic) Base64URL() string

Base64URL is the media encoded as a base64 URL.

func (Generic) Data

func (g Generic) Data() []byte

Data returns the media's raw data.

func (Generic) MIME

func (g Generic) MIME() string

MIME returns the media's MIME type.

type JPEGImage

type JPEGImage []byte

JPEGImage holds the binary data of a JPEG image.

func (JPEGImage) Base64URL

func (i JPEGImage) Base64URL() string

Base64URL is JPEG image encoded as a base64 URL.

func (JPEGImage) Data

func (i JPEGImage) Data() []byte

Data returns the JPEG image as raw bytes.

func (JPEGImage) MIME

func (JPEGImage) MIME() string

MIME returns the MIME type for JPEG images.

type Media

type Media interface {
	// Base64URL is the media encoded as a base64 URL.
	Base64URL() string

	// MIME returns the media's MIME type.
	MIME() string

	// Data returns the media's raw data.
	Data() []byte
}

Media holds a piece of binary data.

func NewMedia

func NewMedia(mime string, data []byte) Media

NewMedia will create a new appropriate media structure based on the MIME type provided. If no suitable structure exists, a Generic one will be used.

type PNGImage

type PNGImage []byte

PNGImage holds the binary data of a PNG image.

func (PNGImage) Base64URL

func (i PNGImage) Base64URL() string

Base64URL is PNG image encoded as a base64 URL.

func (PNGImage) Data

func (i PNGImage) Data() []byte

Data returns the PNG image as raw bytes.

func (PNGImage) MIME

func (PNGImage) MIME() string

MIME returns the MIME type for PNG images.

Jump to

Keyboard shortcuts

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