storage

package
v1.0.1-0...-39f75b5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.Reader
	io.Writer
	io.Seeker
	io.Closer
	Stat() (os.FileInfo, error)
}

File ...

type FileSystem

type FileSystem interface {
	ListFiles() ([]*proto.FileSpec, error)
	DeleteFile(path string) error
	OpenFile(path string) (File, error)
	WriteFile(spec *proto.FileSpec, r io.Reader) error
	Resolve(path string) string
}

文件子系统接口。 所谓“子”,就是针对某篇文章。 TODO 应该用标准的接口。

type Local

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

针对某篇文章的文件系统实现类。 目录结构:配置的文章附件根目录/文章编号/附件路径。 TODO 改成全局一个实例统一管理所有文章的文件。

func NewLocal

func NewLocal(root string, sub string, options ...Option) *Local

func (*Local) DeleteFile

func (fs *Local) DeleteFile(path string) error

func (*Local) ListFiles

func (fs *Local) ListFiles() ([]*proto.FileSpec, error)

func (*Local) Open

func (fs *Local) Open(name string) (fspkg.File, error)

func (*Local) OpenFile

func (fs *Local) OpenFile(path string) (File, error)

func (*Local) Resolve

func (fs *Local) Resolve(path string) string

func (*Local) WriteFile

func (fs *Local) WriteFile(spec *proto.FileSpec, r io.Reader) error

type Option

type Option func(*Local)

func WithMaxFileSize

func WithMaxFileSize(size int32) Option

Jump to

Keyboard shortcuts

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