Documentation
¶
Index ¶
- Constants
- func Destination(driver string, cfg map[string]any) string
- func DriverOf(destination string) string
- func TrackUpload(ctx context.Context, db Execer, path, destination string) error
- func UntrackUpload(ctx context.Context, db Execer, path, destination string) error
- type AzureDriver
- func (d *AzureDriver) Delete(ctx context.Context, path string) error
- func (d *AzureDriver) Exists(ctx context.Context, path string) (bool, error)
- func (d *AzureDriver) Get(ctx context.Context, path string) (io.ReadCloser, error)
- func (d *AzureDriver) Put(ctx context.Context, path string, reader io.Reader, _ int64) error
- type Execer
- type FTPDriver
- func (d *FTPDriver) Delete(_ context.Context, filePath string) error
- func (d *FTPDriver) Exists(_ context.Context, filePath string) (bool, error)
- func (d *FTPDriver) Get(_ context.Context, filePath string) (io.ReadCloser, error)
- func (d *FTPDriver) Put(_ context.Context, filePath string, reader io.Reader, _ int64) error
- type GCSDriver
- func (d *GCSDriver) Delete(ctx context.Context, path string) error
- func (d *GCSDriver) Exists(ctx context.Context, path string) (bool, error)
- func (d *GCSDriver) Get(ctx context.Context, path string) (io.ReadCloser, error)
- func (d *GCSDriver) Put(ctx context.Context, path string, reader io.Reader, _ int64) error
- type LocalDriver
- func (d *LocalDriver) Delete(_ context.Context, path string) error
- func (d *LocalDriver) Exists(_ context.Context, path string) (bool, error)
- func (d *LocalDriver) Get(_ context.Context, path string) (io.ReadCloser, error)
- func (d *LocalDriver) Put(_ context.Context, path string, reader io.Reader, _ int64) error
- type S3Driver
- func (d *S3Driver) Delete(ctx context.Context, path string) error
- func (d *S3Driver) Exists(ctx context.Context, path string) (bool, error)
- func (d *S3Driver) Get(ctx context.Context, path string) (io.ReadCloser, error)
- func (d *S3Driver) Put(ctx context.Context, path string, reader io.Reader, size int64) error
- type SFTPDriver
- func (d *SFTPDriver) Delete(_ context.Context, filePath string) error
- func (d *SFTPDriver) Exists(_ context.Context, filePath string) (bool, error)
- func (d *SFTPDriver) Get(_ context.Context, filePath string) (io.ReadCloser, error)
- func (d *SFTPDriver) Put(_ context.Context, filePath string, reader io.Reader, _ int64) error
- type StorageDriver
- type Upload
Constants ¶
const FilesTable = "_supacraft_files"
FilesTable records every upload in the tenant's own database. Remote drivers store files at the bucket (or directory) root with nothing that marks them as the tenant's, so purging a tenant deletes exactly these. Project validation reserves the "_supacraft_" table prefix.
Variables ¶
This section is empty.
Functions ¶
func Destination ¶ added in v0.3.0
Destination identifies where a driver configuration stores files, so a purge after the storage settings changed knows which records it can delete. It is the driver name plus a hash of the location (bucket, host, root...): the location may come from a secret and is not stored.
func TrackUpload ¶ added in v0.3.0
TrackUpload records path before the file is written, so a file can't exist in storage without a record.
Types ¶
type AzureDriver ¶
type AzureDriver struct {
// contains filtered or unexported fields
}
func NewAzureDriver ¶
func NewAzureDriver(cfg map[string]any) (*AzureDriver, error)
func (*AzureDriver) Get ¶
func (d *AzureDriver) Get(ctx context.Context, path string) (io.ReadCloser, error)
type Execer ¶ added in v0.3.0
type Execer interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
Execer is the part of *sql.DB (and *tenant.DB) tracking needs.
type FTPDriver ¶
type FTPDriver struct {
// contains filtered or unexported fields
}
type GCSDriver ¶
type GCSDriver struct {
// contains filtered or unexported fields
}
type LocalDriver ¶
type LocalDriver struct {
// contains filtered or unexported fields
}
func NewLocalDriver ¶
func NewLocalDriver(basePath string) *LocalDriver
func (*LocalDriver) Get ¶
func (d *LocalDriver) Get(_ context.Context, path string) (io.ReadCloser, error)
type S3Driver ¶
type S3Driver struct {
// contains filtered or unexported fields
}
type SFTPDriver ¶
type SFTPDriver struct {
// contains filtered or unexported fields
}
func NewSFTPDriver ¶
func NewSFTPDriver(cfg map[string]any) (*SFTPDriver, error)
func (*SFTPDriver) Get ¶
func (d *SFTPDriver) Get(_ context.Context, filePath string) (io.ReadCloser, error)
type StorageDriver ¶
type StorageDriver interface {
Put(ctx context.Context, path string, reader io.Reader, size int64) error
Get(ctx context.Context, path string) (io.ReadCloser, error)
Delete(ctx context.Context, path string) error
Exists(ctx context.Context, path string) (bool, error)
}
StorageDriver is the interface all storage backends implement.