Documentation
¶
Overview ¶
Package filepg stores Files in PostgreSQL: metadata in source_files and content in large objects.
Index ¶
- func ReadSourceForCopy(ctx context.Context, tx pgx.Tx, tenant pgtype.UUID, id string, limit int64) ([]byte, error)
- type Store
- func (s *Store) Create(ctx context.Context, tenantID string, ...) (files.File, error)
- func (s *Store) Delete(ctx context.Context, tenantID, fileID string) error
- func (s *Store) Get(ctx context.Context, tenantID, fileID string) (files.File, error)
- func (s *Store) List(ctx context.Context, tenantID string, query files.ListQuery) (files.Page, error)
- func (s *Store) Read(ctx context.Context, tenantID, fileID string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadSourceForCopy ¶ added in v0.0.10
func ReadSourceForCopy(ctx context.Context, tx pgx.Tx, tenant pgtype.UUID, id string, limit int64) ([]byte, error)
ReadSourceForCopy reads, in the caller's transaction, the content of the tenant's File for a copy of at most limit bytes. It holds a share lock on the File until that transaction ends, so a Delete waits for the copy. A malformed or missing File is files.ErrNotFound and a larger one files.ErrTooLarge; content that does not match its recorded size is an internal error.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Create ¶
func (s *Store) Create(ctx context.Context, tenantID string, write func(io.Writer) (files.Upload, error)) (files.File, error)
Create writes the content into a large object and stores the File and its write audit in the same transaction, so a failed upload leaves nothing.
func (*Store) Delete ¶
Delete removes the row and its large object and records the write audit in one transaction.