Documentation
¶
Overview ¶
Package imageasset validates and privately stores image inputs before they cross into UI or provider-specific message code.
Stored objects are addressed by their complete SHA-256 digest. References deliberately retain only bounded display metadata and never the source path.
Index ¶
- Variables
- type Limits
- type Ref
- type Store
- func (s *Store) AdmitBytes(ctx context.Context, displayName string, data []byte) (Ref, error)
- func (s *Store) AdmitBytesChecked(ctx context.Context, displayName string, data []byte, check func(Ref) error) (Ref, error)
- func (s *Store) AdmitFile(ctx context.Context, path string) (Ref, error)
- func (s *Store) AdmitFileChecked(ctx context.Context, path string, check func(Ref) error) (Ref, error)
- func (s *Store) Load(ctx context.Context, ref Ref) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Limits ¶
Limits bounds image admission before any provider sees the image. Pixel count is checked separately from each dimension to reject decompression-bomb shaped inputs with otherwise plausible headers.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns conservative limits suitable for interactive image attachments. Callers may provide stricter limits for a specific provider.
type Ref ¶
type Ref struct {
Digest string `json:"sha256"`
MIMEType string `json:"mime_type"`
Name string `json:"name"`
SizeBytes int64 `json:"size_bytes"`
Width int `json:"width"`
Height int `json:"height"`
}
Ref is safe to persist with a session. Digest is the complete lowercase SHA-256 digest, while Handle is a compact presentation identifier derived from it. Name contains only a sanitized basename, never the source path.
func (Ref) Handle ¶
Handle returns a short display-only identifier. Durable lookup and integrity checks must always use the complete Digest.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns a private content-addressed image object directory.
func (*Store) AdmitBytes ¶
AdmitBytes validates an in-memory image (for example, a future native clipboard adapter), stores it privately, and returns a durable reference.
func (*Store) AdmitBytesChecked ¶
func (s *Store) AdmitBytesChecked(ctx context.Context, displayName string, data []byte, check func(Ref) error) (Ref, error)
AdmitBytesChecked validates in-memory image bytes and invokes check with the path-free reference before publication. A rejected check leaves no new object behind.
func (*Store) AdmitFile ¶
AdmitFile validates an explicitly selected regular file, copies it into the private content-addressed store, and returns a path-free reference. Explicit file selection follows a source symlink; the opened descriptor is still validated as a regular file by safeio.
func (*Store) AdmitFileChecked ¶
func (s *Store) AdmitFileChecked(ctx context.Context, path string, check func(Ref) error) (Ref, error)
AdmitFileChecked validates an explicitly selected image and invokes check with its path-free reference before publishing bytes to the private object store. A rejected check leaves no new object behind. The check must be deterministic and must not retain the reference beyond the call.