attachment

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package attachment provides file storage for channel attachments. Files are stored on the local filesystem under {stateDir}/attachments/{id}/{filename}. This is a stop-gap implementation; the storage backend can be swapped later.

Index

Constants

View Source
const MaxFileSize = 50 * 1024 * 1024

MaxFileSize is the default maximum file size (50MB).

View Source
const MaxFilesPerMessage = 5

MaxFilesPerMessage is the default maximum number of attachments per message.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	CreatedAt time.Time `json:"created_at"`
	ID        string    `json:"id"`
	Filename  string    `json:"filename"`
	MIMEType  string    `json:"mime_type"`
	Channel   string    `json:"channel"`
	Sender    string    `json:"sender"`
	Size      int64     `json:"size"`
}

Metadata holds information about a stored attachment.

type Store

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

Store manages attachment file storage on the local filesystem.

func NewStore

func NewStore(stateDir string) *Store

NewStore creates an attachment store rooted at the given directory.

func (*Store) AddSharedDir

func (s *Store) AddSharedDir(dir string)

AddSharedDir adds a directory to search when looking up files by name. Files in shared dirs are served by filename (not by hex ID).

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes an attachment by ID.

func (*Store) Get

func (s *Store) Get(id string) ([]byte, *Metadata, error)

Get returns the file data and metadata for the given attachment ID. It first checks the attachments directory by hex ID, then searches shared directories by filename (for Playwright screenshots, etc.).

func (*Store) Save

func (s *Store) Save(data []byte, filename, channel, sender string) (*Metadata, error)

Save stores file data and returns metadata. The filename is sanitized.

Jump to

Keyboard shortcuts

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