Documentation
¶
Overview ¶
Package upload owns request-scoped temporary files behind typed HTTP handles.
Index ¶
- type Batch
- type CleanupError
- type Config
- type File
- func (f File) ClientContentType() string
- func (f File) ContentType() string
- func (f File) Extension() string
- func (File) GoString() string
- func (f File) IsZero() bool
- func (File) MarshalJSON() ([]byte, error)
- func (f File) Name() string
- func (f File) Open(ctx context.Context) (io.ReadSeekCloser, error)
- func (f File) Size() int64
- func (File) String() string
- type Limit
- type LimitError
- type ReadError
- type Reader
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch owns all temporary files and readers for one request. Close waits for active captures/reads, closes readers, and removes only owned files. No recursive deletion or client-provided path participates in cleanup.
func (*Batch) Capture ¶
func (b *Batch) Capture(ctx context.Context, source io.Reader, name, declaredType string) (result File, err error)
Capture stores bytes with a fixed scratch buffer. Limits account for attempted writes and file creation; failed attempts do not replenish the request budget. The caller still owns the incoming reader. No partial File is published.
type CleanupError ¶
type CleanupError struct{ Cause error }
CleanupError reports a failed local cleanup rather than misclassifying an incoming reader failure as the complete outcome. The cause remains private.
func (*CleanupError) Error ¶
func (*CleanupError) Error() string
func (*CleanupError) Unwrap ¶
func (e *CleanupError) Unwrap() error
type Config ¶
Config bounds capture bytes, created files and concurrently open readers. Empty TempDirectory uses the operating system's temporary directory.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is an opaque handle to a fully captured request-owned upload. Its zero value is absent. Metadata remains readable after cleanup; Open does not.
func (File) ClientContentType ¶
ClientContentType is untrusted metadata supplied by the client.
func (File) ContentType ¶
ContentType is Go's bounded content sniff, not proof of a valid image/document.
func (File) MarshalJSON ¶
type LimitError ¶
type LimitError struct{ Kind Limit }
func (*LimitError) Error ¶
func (*LimitError) Error() string
type ReadError ¶
type ReadError struct{ Cause error }
ReadError distinguishes failed incoming bytes from local filesystem failures. Error formatting never invokes the underlying reader's error methods.
type Source ¶
type Source interface {
Open(context.Context) (io.ReadSeekCloser, error)
Name() string
ClientContentType() string
}
Source is the shared structural contract for a captured file that a feature can open. The caller owns the file; each operation closes the reader it opens. Name and ClientContentType are untrusted display/type hints.