attachments

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT Purpose: attachment store with SHA-256 dedup and magic-byte MIME detection. Supports images (PNG, JPEG, GIF), PDFs, and text. Backed by filesystem (no bbolt needed; files are content-addressed by hash).

Index

Constants

View Source
const (
	MaxSize       = 50 * 1024 * 1024
	DefaultExpiry = 30 * 24 * time.Hour
)

Variables

View Source
var (
	ErrTooLarge = errors.New("attachment exceeds 50MB")
	ErrNotFound = errors.New("attachment not found")
)

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID        string    `json:"id"`
	Hash      string    `json:"hash"`
	Name      string    `json:"name"`
	MIME      string    `json:"mime"`
	Size      int64     `json:"size"`
	Path      string    `json:"path"`
	Created   time.Time `json:"created"`
	ExpiresAt time.Time `json:"expires_at"`
}

func (*Attachment) IsImage

func (a *Attachment) IsImage() bool

func (*Attachment) Marker

func (a *Attachment) Marker() string

type Store

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

func NewStore

func NewStore() (*Store, error)

func NewStoreAt

func NewStoreAt(dir string) (*Store, error)

func (*Store) Attach

func (s *Store) Attach(srcPath string) (*Attachment, error)

func (*Store) AttachReader

func (s *Store) AttachReader(r io.Reader, name string, size int64) (*Attachment, error)

func (*Store) BaseDir

func (s *Store) BaseDir() string

func (*Store) Get

func (s *Store) Get(hash string) (*Attachment, error)

func (*Store) Prune

func (s *Store) Prune() (int, error)

Jump to

Keyboard shortcuts

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