attachments

package
v1.7.3 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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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