filestore

package
v0.0.0-...-3ac8fd0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore

type FileStore interface {
	// list the items at a certain path
	List(ctx context.Context, path string) ([]FileStoreItem, error)
	Get(ctx context.Context, path string) (FileStoreItem, error)
	CreateFolder(ctx context.Context, path string) (FileStoreItem, error)
	Upload(ctx context.Context, path string, r io.Reader) (FileStoreItem, error)
	Rename(ctx context.Context, path string, newPath string) (FileStoreItem, error)
	Delete(ctx context.Context, path string) error
}

type FileStoreItem

type FileStoreItem struct {
	// timestamp
	Created int64 `json:"created"`
	// bytes
	Size int64 `json:"size"`
	// is this thing a folder or not?
	Directory bool `json:"directory"`
	// the filename
	Name string `json:"name"`
	// the relative path to the file from the base path of the storage instance
	Path string `json:"path"`
	// the URL that can be used to load the object directly
	URL string `json:"url"`
}

type FileStoreOptions

type FileStoreOptions struct {
	Type         FileStoreType
	LocalFSPath  string
	GCSKeyBase64 string
	GCSKeyFile   string
	GCSBucket    string
}

type FileStoreType

type FileStoreType string
const (
	FileStoreTypeLocalFS  FileStoreType = "fs"
	FileStoreTypeLocalGCS FileStoreType = "gcs"
)

type FileSystemStorage

type FileSystemStorage struct {
	// contains filtered or unexported fields
}

func NewFileSystemStorage

func NewFileSystemStorage(basePath string, baseURL string) *FileSystemStorage

func (*FileSystemStorage) CreateFolder

func (s *FileSystemStorage) CreateFolder(ctx context.Context, path string) (FileStoreItem, error)

func (*FileSystemStorage) Delete

func (s *FileSystemStorage) Delete(ctx context.Context, path string) error

func (*FileSystemStorage) Get

func (*FileSystemStorage) List

func (s *FileSystemStorage) List(ctx context.Context, prefix string) ([]FileStoreItem, error)

func (*FileSystemStorage) Rename

func (s *FileSystemStorage) Rename(ctx context.Context, path string, newPath string) (FileStoreItem, error)

func (*FileSystemStorage) Upload

func (s *FileSystemStorage) Upload(ctx context.Context, path string, r io.Reader) (FileStoreItem, error)

type FilestoreConfig

type FilestoreConfig struct {
	// this will be the virtual path from the storage instance
	// to the users root directory
	// we use this to strip the full paths in the frontend so we can deal with only relative paths
	UserPrefix string            `json:"user_prefix"`
	Folders    []FilestoreFolder `json:"folders"`
}

type FilestoreFolder

type FilestoreFolder struct {
	Name     string `json:"name"`
	Readonly bool   `json:"readonly"`
}

top level filestore folders that have special meaning

type GCSStorage

type GCSStorage struct {
	// contains filtered or unexported fields
}

func NewGCSStorage

func NewGCSStorage(ctx context.Context, bucketName, serviceAccountKeyFile string) (*GCSStorage, error)

func (*GCSStorage) CreateFolder

func (s *GCSStorage) CreateFolder(ctx context.Context, path string) (FileStoreItem, error)

func (*GCSStorage) Delete

func (s *GCSStorage) Delete(ctx context.Context, path string) error

func (*GCSStorage) Get

func (s *GCSStorage) Get(ctx context.Context, path string) (FileStoreItem, error)

func (*GCSStorage) List

func (s *GCSStorage) List(ctx context.Context, prefix string) ([]FileStoreItem, error)

func (*GCSStorage) Rename

func (s *GCSStorage) Rename(ctx context.Context, path string, newPath string) (FileStoreItem, error)

func (*GCSStorage) Upload

func (s *GCSStorage) Upload(ctx context.Context, path string, r io.Reader) (FileStoreItem, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL