Documentation
¶
Overview ¶
Package media owns logical files and business references, independent of providers.
Index ¶
- Variables
- type Access
- type ArchiveEntry
- type ArchiveManifest
- type ArchiveRequest
- type Authorizer
- type Binding
- type Config
- type Event
- type EventData
- type File
- type FileListing
- type FilePage
- type FileView
- type Job
- type Principal
- type Profile
- type Protection
- type Reference
- type Replay
- type Repository
- type Service
- func (s *Service) Approve(ctx context.Context, p Principal, id, key string) (Version, error)
- func (s *Service) Archive(ctx context.Context, p Principal, ids []string, dst io.Writer) error
- func (s *Service) ArchiveLimits() (files int, bytes int64)
- func (s *Service) ArchiveManifest(ctx context.Context, p Principal, ids []string) (ArchiveManifest, error)
- func (s *Service) Attach(ctx context.Context, p Principal, id, key string, b Binding) (Reference, error)
- func (s *Service) CancelUpload(ctx context.Context, p Principal, id, key string) (Version, error)
- func (s *Service) Close(ctx context.Context) error
- func (s *Service) CreateUpload(ctx context.Context, p Principal, key string, r UploadRequest) (Version, error)
- func (s *Service) DeleteFile(ctx context.Context, p Principal, id, key string, revision int64) (FileView, error)
- func (s *Service) Download(ctx context.Context, p Principal, id string, dst io.Writer) error
- func (s *Service) GetFile(ctx context.Context, p Principal, id string) (FileView, error)
- func (s *Service) GetReference(ctx context.Context, p Principal, id string) (Reference, error)
- func (s *Service) GetUpload(ctx context.Context, p Principal, id string) (VersionView, error)
- func (s *Service) GetVersion(ctx context.Context, p Principal, id string) (VersionView, error)
- func (s *Service) ListFiles(ctx context.Context, p Principal, limit int, cursor string) (FilePage, error)
- func (s *Service) Publish(ctx context.Context, p Principal, id, key string) (Reference, error)
- func (s *Service) ReferenceVersion(ctx context.Context, p Principal, id string) (Version, error)
- func (s *Service) Release(ctx context.Context, p Principal, id, key string) (Reference, error)
- func (s *Service) ReviewDownload(ctx context.Context, p Principal, id string, dst io.Writer) error
- func (s *Service) RunOne(ctx context.Context, worker string) (bool, error)
- func (s *Service) SetFileState(ctx context.Context, p Principal, id, key string, revision int64, ...) (FileView, error)
- func (s *Service) Sweep(ctx context.Context, n int, after string) (string, error)
- func (s *Service) Upload(ctx context.Context, p Principal, id, key string, src io.Reader) (Version, error)
- type Store
- type Transaction
- type UploadRequest
- type Version
- type VersionView
Constants ¶
This section is empty.
Variables ¶
var ( ErrInput = errors.New("media_invalid_input") ErrDenied = errors.New("media_permission_denied") ErrNotFound = errors.New("media_not_found") ErrConflict = errors.New("media_conflict") ErrIntegrity = errors.New("media_integrity_failed") ErrType = errors.New("media_content_type_rejected") ErrCapacity = errors.New("media_capacity_unavailable") ErrExpired = errors.New("media_upload_expired") )
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access struct {
FileID, VersionID, Purpose string
Owner Principal
Protection Protection
Reference *Reference
}
Access is trusted persisted context, never an authorization claim from JSON.
type ArchiveEntry ¶
type ArchiveManifest ¶
type ArchiveManifest struct {
Entries []ArchiveEntry `json:"entries"`
TotalSize int64 `json:"total_size"`
}
type ArchiveRequest ¶
type ArchiveRequest struct {
References []string `json:"references"`
}
type Authorizer ¶
type Event ¶
type Event struct {
SpecVersion string `json:"specversion"`
Source string `json:"source"`
DataContentType string `json:"datacontenttype"`
Data EventData `json:"data"`
ID string `json:"id"`
Type string `json:"type"`
Subject string `json:"subject"`
Revision int64 `json:"-"`
Time time.Time `json:"time"`
Actor Principal `json:"-"`
}
type FileListing ¶
type FileListing struct {
File
Protection Protection
}
type Profile ¶
type Profile struct {
Module string `json:"module"`
Quarantine Protection `json:"quarantine"`
Published Protection `json:"published"`
AllowedTypes []string `json:"allowed_types"`
MaxSize int64 `json:"max_size"`
}
type Protection ¶
type Protection = storage.Protection
type Replay ¶
type Replay struct {
Key, Digest string
Result json.RawMessage
}
type Repository ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(r Repository, a Authorizer, store Store, c Config) (*Service, error)
func (*Service) Archive ¶
Archive streams verified entries without retaining archive bytes. A single transfer slot covers the entire package, including all entry downloads.
func (*Service) ArchiveLimits ¶
ArchiveLimits returns the configured limits so a composing business service can reject an incompatible package policy before accepting user requests.
func (*Service) ArchiveManifest ¶
func (*Service) CancelUpload ¶
func (*Service) CreateUpload ¶
func (*Service) DeleteFile ¶
func (*Service) Download ¶
Only a currently active business reference can deliver content. Storage verifies the complete bytes before Write, then this guard rechecks access.
func (*Service) GetReference ¶
func (*Service) GetVersion ¶
func (*Service) ReferenceVersion ¶
func (*Service) ReviewDownload ¶
ReviewDownload serves complete, verified bytes to a separately authorized reviewer. It never activates a reference or grants ordinary download access.
func (*Service) SetFileState ¶
type Store ¶
type Store interface {
Create(context.Context, Principal, string, storage.CreateRequest) (storage.Status, error)
Status(context.Context, Principal, string) (storage.Status, error)
Ingest(context.Context, Principal, string, string, io.Reader) (storage.Status, error)
Reference(context.Context, Principal, string, string, storage.Reference, bool) (storage.Status, error)
Delete(context.Context, Principal, string, string, int64) (storage.Status, error)
ChangeProtection(context.Context, Principal, string, string, int64, Protection) (storage.Status, error)
Download(context.Context, Principal, string, io.Writer) error
ReviewDownload(context.Context, Principal, string, io.Writer) error
}
Store is fulfilled by the storage public service. The distinct service actor must have explicit grants; end users never inherit those grants.
type Transaction ¶
type Transaction interface {
ReuseCandidates(Principal, UploadRequest) ([]Version, error)
Lock(string) error
File(string) (File, error)
Files(Principal, int, string) ([]FileListing, error)
SaveFile(File) error
Version(string) (Version, error)
Upload(string) (Version, error)
Reference(string) (Version, Reference, error)
Versions(string) ([]Version, error)
ScanVersions(int, string) ([]Version, error)
SaveVersion(Version) error
Counts(Principal) (files, open int, err error)
Replay(string) (Replay, error)
SaveReplay(Replay) error
Job(string) (Job, error)
SaveJob(Job) error
Event(Event) error
}
type UploadRequest ¶
type Version ¶
type Version struct {
Reused bool `json:"reused,omitempty"`
ReuseSource string `json:"-"`
ReuseObject string `json:"-"`
ID string `json:"id"`
FileID string `json:"file_id"`
Number int `json:"number"`
Revision int64 `json:"revision"`
UploadID string `json:"upload_id"`
Filename string `json:"filename"`
ContentType string `json:"content_type"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
State string `json:"state"`
Approved bool `json:"approved"`
ExpiresAt time.Time `json:"upload_expires_at"`
RetainUntil time.Time `json:"retain_until"`
CleanupComplete bool `json:"cleanup_complete"`
ErrorCode string `json:"error_code"`
// Persistence uses Record so internal locations never enter public JSON.
ObjectID string `json:"-"`
ObjectIssued bool `json:"-"`
TypeValidated bool `json:"-"`
UploadGeneration int64 `json:"-"`
UploadUntil time.Time `json:"-"`
Profile Profile `json:"-"`
References []Reference `json:"-"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package httpapi exposes authenticated file operations without provider details.
|
Package httpapi exposes authenticated file operations without provider details. |
|
Package postgres owns media metadata and migrations, using a separate role.
|
Package postgres owns media metadata and migrations, using a separate role. |
|
Package sdk provides primitives to interact with the openapi HTTP API.
|
Package sdk provides primitives to interact with the openapi HTTP API. |