media

package
v0.0.0-...-f0e47c8 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase64

func DecodeBase64(b64Data string) ([]byte, string, error)

DecodeBase64 decodes raw/base64 data or data URIs and returns bytes plus mime type.

func DecodeDataURI

func DecodeDataURI(raw string) ([]byte, string, error)

DecodeDataURI decodes a data URI (both base64 and percent-encoded) and returns the decoded bytes plus the mime type extracted from the URI header. It returns an empty mime type string if no media type is specified in the URI.

func DownloadURL

func DownloadURL(ctx context.Context, rawURL, fallbackMime string, maxBytes int64) ([]byte, string, error)

DownloadURL fetches a file from rawURL over HTTP(S) and returns the bytes, resolved MIME type, and any error. When maxBytes > 0 the download is rejected if the server-advertised Content-Length or the actual body exceeds that limit. fallbackMime is used when the server does not return a usable Content-Type header.

func FallbackFilenameForMIME

func FallbackFilenameForMIME(mimeType string) string

func MessageTypeForMIME

func MessageTypeForMIME(mimeType string) event.MessageType

func ParseDataURI

func ParseDataURI(dataURI string) (string, string, error)

ParseDataURI parses a base64 data URI and returns raw base64 data and mime type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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