gitea: code.gitea.io/gitea/modules/storage Index | Files

package storage

import "code.gitea.io/gitea/modules/storage"

Index

Package Files

helper.go local.go minio.go storage.go

Variables

var (
    // ErrURLNotSupported represents url is not supported
    ErrURLNotSupported = errors.New("url method not supported")
    // ErrIterateObjectsNotSupported represents IterateObjects not supported
    ErrIterateObjectsNotSupported = errors.New("iterateObjects method not supported")
)

func Copy Uses

func Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, srcPath string) (int64, error)

Copy copys a file from source ObjectStorage to dest ObjectStorage

func Init Uses

func Init() error

Init init the stoarge

func IsErrInvalidConfiguration Uses

func IsErrInvalidConfiguration(err error) bool

IsErrInvalidConfiguration checks if an error is an ErrInvalidConfiguration

func RegisterStorageType Uses

func RegisterStorageType(typ Type, fn func(ctx context.Context, cfg interface{}) (ObjectStorage, error))

RegisterStorageType registers a provided storage type with a function to create it

func SaveFrom Uses

func SaveFrom(objStorage ObjectStorage, p string, callback func(w io.Writer) error) error

SaveFrom saves data to the ObjectStorage with path p from the callback

type ErrInvalidConfiguration Uses

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

ErrInvalidConfiguration is called when there is invalid configuration for a storage

func (ErrInvalidConfiguration) Error Uses

func (err ErrInvalidConfiguration) Error() string

type LocalStorage Uses

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

LocalStorage represents a local files storage

func (*LocalStorage) Delete Uses

func (l *LocalStorage) Delete(path string) error

Delete delete a file

func (*LocalStorage) IterateObjects Uses

func (l *LocalStorage) IterateObjects(fn func(path string, obj Object) error) error

IterateObjects iterates across the objects in the local storage

func (*LocalStorage) Open Uses

func (l *LocalStorage) Open(path string) (Object, error)

Open a file

func (*LocalStorage) Save Uses

func (l *LocalStorage) Save(path string, r io.Reader) (int64, error)

Save a file

func (*LocalStorage) Stat Uses

func (l *LocalStorage) Stat(path string) (os.FileInfo, error)

Stat returns the info of the file

func (*LocalStorage) URL Uses

func (l *LocalStorage) URL(path, name string) (*url.URL, error)

URL gets the redirect URL to a file

type LocalStorageConfig Uses

type LocalStorageConfig struct {
    Path string `ini:"PATH"`
}

LocalStorageConfig represents the configuration for a local storage

type Mappable Uses

type Mappable interface {
    MapTo(v interface{}) error
}

Mappable represents an interface that can MapTo another interface

type MinioStorage Uses

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

MinioStorage returns a minio bucket storage

func (*MinioStorage) Delete Uses

func (m *MinioStorage) Delete(path string) error

Delete delete a file

func (*MinioStorage) IterateObjects Uses

func (m *MinioStorage) IterateObjects(fn func(path string, obj Object) error) error

IterateObjects iterates across the objects in the miniostorage

func (*MinioStorage) Open Uses

func (m *MinioStorage) Open(path string) (Object, error)

Open open a file

func (*MinioStorage) Save Uses

func (m *MinioStorage) Save(path string, r io.Reader) (int64, error)

Save save a file to minio

func (*MinioStorage) Stat Uses

func (m *MinioStorage) Stat(path string) (os.FileInfo, error)

Stat returns the stat information of the object

func (*MinioStorage) URL Uses

func (m *MinioStorage) URL(path, name string) (*url.URL, error)

URL gets the redirect URL to a file. The presigned link is valid for 5 minutes.

type MinioStorageConfig Uses

type MinioStorageConfig struct {
    Endpoint        string `ini:"MINIO_ENDPOINT"`
    AccessKeyID     string `ini:"MINIO_ACCESS_KEY_ID"`
    SecretAccessKey string `ini:"MINIO_SECRET_ACCESS_KEY"`
    Bucket          string `ini:"MINIO_BUCKET"`
    Location        string `ini:"MINIO_LOCATION"`
    BasePath        string `ini:"MINIO_BASE_PATH"`
    UseSSL          bool   `ini:"MINIO_USE_SSL"`
}

MinioStorageConfig represents the configuration for a minio storage

type NewStorageFunc Uses

type NewStorageFunc func(ctx context.Context, cfg interface{}) (ObjectStorage, error)

NewStorageFunc is a function that creates a storage

type Object Uses

type Object interface {
    io.ReadCloser
    io.Seeker
    Stat() (os.FileInfo, error)
}

Object represents the object on the storage

type ObjectStorage Uses

type ObjectStorage interface {
    Open(path string) (Object, error)
    Save(path string, r io.Reader) (int64, error)
    Stat(path string) (os.FileInfo, error)
    Delete(path string) error
    URL(path, name string) (*url.URL, error)
    IterateObjects(func(path string, obj Object) error) error
}

ObjectStorage represents an object storage to handle a bucket and files

var (
    // Attachments represents attachments storage
    Attachments ObjectStorage

    // LFS represents lfs storage
    LFS ObjectStorage

    // Avatars represents user avatars storage
    Avatars ObjectStorage
    // RepoAvatars represents repository avatars storage
    RepoAvatars ObjectStorage
)

func NewLocalStorage Uses

func NewLocalStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error)

NewLocalStorage returns a local files

func NewMinioStorage Uses

func NewMinioStorage(ctx context.Context, cfg interface{}) (ObjectStorage, error)

NewMinioStorage returns a minio storage

func NewStorage Uses

func NewStorage(typStr string, cfg interface{}) (ObjectStorage, error)

NewStorage takes a storage type and some config and returns an ObjectStorage or an error

type Type Uses

type Type string

Type is a type of Storage

const LocalStorageType Type = "local"

LocalStorageType is the type descriptor for local storage

const MinioStorageType Type = "minio"

MinioStorageType is the type descriptor for minio storage

Package storage imports 17 packages (graph) and is imported by 16 packages. Updated 2020-12-09. Refresh now. Tools for package owners.