attachment

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const BytesPerMegabyte = 1024 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type AType

type AType string
const (
	Document AType = "document"
	Video    AType = "video"
	Audio    AType = "audio"
	Photo    AType = "photo"
)

func DetectType

func DetectType(fileName string) AType

DetectType determines the file type based on its extension. Falls back to Document if unknown.

func (AType) String

func (a AType) String() string

type Attachment

type Attachment struct {
	AType     AType
	FileName  string
	SizeBytes int64
	File      io.ReadCloser // todo rename to FileReadCloser
}

func (*Attachment) Close

func (a *Attachment) Close() error

type Attachments

type Attachments []*Attachment

func (Attachments) Close

func (a Attachments) Close() error

type FileOpener

type FileOpener interface {
	Open(string) (*OpenedFile, error)
}

type Loader

type Loader struct {
	FileOpener                  FileOpener
	IsEverythingDocument        bool
	MaxTotalAttachments         int
	MaxPhotoAttachmentSizeBytes int64
	MaxAttachmentSizeBytes      int64
	MaxTotalSizeBytes           int64
}

Loader validates and loads attachments according to configured limits.

func (*Loader) LoadMultipleAttachments

func (l *Loader) LoadMultipleAttachments(filePaths []string) (Attachments, error)

type OSFileOpener

type OSFileOpener struct{}

func NewOSFileOpener

func NewOSFileOpener() *OSFileOpener

func (*OSFileOpener) Open

func (o *OSFileOpener) Open(path string) (*OpenedFile, error)

type OpenedFile

type OpenedFile struct {
	File      io.ReadCloser
	SizeBytes int64
}

Jump to

Keyboard shortcuts

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