storage

package
v0.0.0-...-932f57c Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem struct {
	Base string
}

FileSystem file system storage

func NewFileSystem

func NewFileSystem(base string) *FileSystem

New initialize FileSystem storage

func (*FileSystem) Delete

func (f *FileSystem) Delete(path string) error

Delete delete file

func (*FileSystem) Get

func (f *FileSystem) Get(path string) (*os.File, error)

Get receive file with given path

func (*FileSystem) GetEndpoint

func (f *FileSystem) GetEndpoint() string

GetEndpoint get endpoint, FileSystem's endpoint is /

func (*FileSystem) GetFullPath

func (f *FileSystem) GetFullPath(path string) string

GetFullPath get full path from absolute/relative path

func (*FileSystem) GetStream

func (f *FileSystem) GetStream(path string) (io.ReadCloser, error)

GetStream get file as stream

func (*FileSystem) GetURL

func (f *FileSystem) GetURL(path string) (url string, err error)

GetURL get public accessible URL

func (*FileSystem) List

func (f *FileSystem) List(path string) ([]*Object, error)

List list all objects under current path

func (*FileSystem) Put

func (f *FileSystem) Put(path string, reader io.Reader) (*Object, error)

Put store a reader into given path

func (f *FileSystem) Symlink(target string, name string) (err error)

Symlink create symbolic link

type Object

type Object struct {
	Path             string
	Name             string
	LastModified     *time.Time
	StorageInterface Storage
}

Object content object

func (Object) Get

func (object Object) Get() (*os.File, error)

Get retrieve object's content

type Storage

type Storage interface {
	Get(path string) (*os.File, error)
	GetStream(path string) (io.ReadCloser, error)
	Put(path string, reader io.Reader) (*Object, error)
	Delete(path string) error
	List(path string) ([]*Object, error)
	GetURL(path string) (string, error)
	GetEndpoint() string
}

Storage define common API to operate storage

type Symlinker

type Symlinker interface {
	Storage

	// Symlink create symbolic link from name to target.
	// If symbolic link creation isn't supported, return ErrSymlinkNotSupported.
	Symlink(target string, name string) (err error)
}

StorageLinker is an Storage interface including methods to create symbolic link.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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