Documentation
¶
Index ¶
- Constants
- func Provider(options ...ProviderOption) runaprovider.Provider
- type CopyDriver
- type Disk
- type DiskOption
- type DiskOptions
- type Driver
- type DriverOption
- type DriverOptions
- type FileInfo
- type FileList
- type FileOption
- type FileOptions
- type Info
- type ListOption
- type ListOptions
- type MoveDriver
- type ProviderOption
- type Registry
- func (registry *Registry) Close(ctx context.Context) error
- func (registry *Registry) Config(store *config.Store)
- func (registry *Registry) Disk(name string, options ...DiskOption)
- func (registry *Registry) Driver(name string) Driver
- func (registry *Registry) Info() []Info
- func (registry *Registry) MustOf(name string) Disk
- func (registry *Registry) Of(name string) (Disk, error)
- func (registry *Registry) RegisterDriver(name string, driver Driver)
- func (registry *Registry) Shutdown(ctx context.Context) error
- type SignedPost
- type SignedURL
- type URLOptions
Constants ¶
const ( DefaultDriver = "local" DiskLocal = "local" DiskPublic = "public" DiskPrivate = "private" DiskCloud = "cloud" )
Variables ¶
This section is empty.
Functions ¶
func Provider ¶
func Provider(options ...ProviderOption) runaprovider.Provider
Provider creates a storage provider.
Types ¶
type CopyDriver ¶ added in v0.1.3
type CopyDriver interface {
Copy(ctx context.Context, from string, to string, options FileOptions) error
}
CopyDriver is implemented by drivers that can copy objects without routing data through the app.
type Disk ¶
type Disk interface {
Put(ctx context.Context, path string, body io.Reader, options ...FileOption) error
PutBytes(ctx context.Context, path string, data []byte, options ...FileOption) error
PutString(ctx context.Context, path string, data string, options ...FileOption) error
Get(ctx context.Context, path string) (io.ReadCloser, FileInfo, error)
GetBytes(ctx context.Context, path string) ([]byte, error)
GetString(ctx context.Context, path string) (string, error)
Delete(ctx context.Context, paths ...string) error
Exists(ctx context.Context, path string) (bool, error)
Size(ctx context.Context, path string) (int64, error)
Info(ctx context.Context, path string) (FileInfo, error)
List(ctx context.Context, prefix string, options ...ListOption) (FileList, error)
Copy(ctx context.Context, from string, to string, options ...FileOption) error
Move(ctx context.Context, from string, to string, options ...FileOption) error
URL(ctx context.Context, path string) (string, error)
TempURL(ctx context.Context, path string, ttl time.Duration) (string, error)
SignPut(ctx context.Context, path string, ttl time.Duration, options ...FileOption) (SignedURL, error)
SignPost(ctx context.Context, path string, ttl time.Duration, options ...FileOption) (SignedPost, error)
}
Disk is the business-facing named filesystem.
type DiskOption ¶
type DiskOption interface {
ApplyDisk(*DiskOptions)
}
DiskOption configures a named disk.
func URLPrefix ¶
func URLPrefix(value string) DiskOption
URLPrefix sets the public URL prefix for this disk.
type DiskOptions ¶
type DiskOptions struct {
Driver string
Prefix string
Public bool
URLPrefix string
Domain string
Meta core.Map
}
DiskOptions stores named disk configuration.
type Driver ¶
type Driver interface {
Name() string
Put(ctx context.Context, path string, body io.Reader, options FileOptions) error
Get(ctx context.Context, path string) (io.ReadCloser, FileInfo, error)
Delete(ctx context.Context, paths ...string) error
Exists(ctx context.Context, path string) (bool, error)
Info(ctx context.Context, path string) (FileInfo, error)
List(ctx context.Context, prefix string, options ListOptions) (FileList, error)
URL(ctx context.Context, path string, options URLOptions) (string, error)
TempURL(ctx context.Context, path string, ttl time.Duration, options URLOptions) (string, error)
SignPut(ctx context.Context, path string, ttl time.Duration, options FileOptions) (SignedURL, error)
SignPost(ctx context.Context, path string, ttl time.Duration, options FileOptions) (SignedPost, error)
Close(ctx context.Context) error
}
Driver is the low-level storage adapter.
func LocalDriver ¶
func LocalDriver(options ...DriverOption) Driver
LocalDriver creates a local filesystem storage driver.
type DriverOption ¶
type DriverOption interface {
ApplyDriver(*DriverOptions)
}
DriverOption configures local or external driver wrappers.
func DriverDomain ¶
func DriverDomain(value string) DriverOption
DriverDomain sets local driver URL domain.
func DriverMeta ¶
func DriverMeta(key string, value any) DriverOption
DriverMeta stores arbitrary driver metadata.
func DriverURLPrefix ¶
func DriverURLPrefix(value string) DriverOption
DriverURLPrefix sets local driver URL prefix.
func Secret ¶
func Secret(value string) DriverOption
Secret sets signing secret for drivers that support signed URLs.
type DriverOptions ¶
type DriverOptions struct {
Name string
Root string
Domain string
URLPrefix string
Secret string
Meta core.Map
}
DriverOptions stores low-level driver configuration.
type FileInfo ¶
type FileInfo struct {
Path string
Size int64
ContentType string
ETag string
LastModified time.Time
Meta core.Map
}
FileInfo describes one stored object.
type FileOption ¶
type FileOption interface {
ApplyFile(*FileOptions)
}
FileOption configures one file operation.
func ContentType ¶
func ContentType(value string) FileOption
ContentType sets content type for one write/sign operation.
func FileMeta ¶
func FileMeta(key string, value any) FileOption
FileMeta stores arbitrary file operation metadata.
type FileOptions ¶
FileOptions stores file operation metadata.
type ListOption ¶ added in v0.1.3
type ListOption interface {
ApplyList(*ListOptions)
}
ListOption configures one list operation.
func Cursor ¶ added in v0.1.3
func Cursor(value string) ListOption
Cursor continues a paginated listing from a previous cursor.
func Limit ¶ added in v0.1.3
func Limit(value int32) ListOption
Limit sets the maximum number of objects returned by one list call.
func Recursive ¶ added in v0.1.3
func Recursive() ListOption
Recursive lists all nested objects under the prefix.
type ListOptions ¶ added in v0.1.3
ListOptions stores object listing controls.
type MoveDriver ¶ added in v0.1.3
type MoveDriver interface {
Move(ctx context.Context, from string, to string, options FileOptions) error
}
MoveDriver is implemented by drivers that can move objects without routing data through the app.
type ProviderOption ¶
type ProviderOption func(*provider)
ProviderOption configures a storage provider.
func RegisterDisk ¶
func RegisterDisk(name string, options ...DiskOption) ProviderOption
RegisterDisk registers a named storage disk.
func RegisterDriver ¶
func RegisterDriver(name string, driver Driver) ProviderOption
RegisterDriver registers a low-level storage driver.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores storage drivers and named disks.
func New ¶
func New(options ...DriverOption) *Registry
New creates a storage registry with default disk names.
func (*Registry) Disk ¶
func (registry *Registry) Disk(name string, options ...DiskOption)
Disk registers or replaces a named disk.
func (*Registry) RegisterDriver ¶
RegisterDriver registers a storage driver.
type SignedPost ¶
SignedPost describes a pre-signed form post.