xfile

package
v0.0.0-...-2beabf4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EmptyETag 空的etag
	EmptyETag = ""
)

Variables

View Source
var (
	ErrFileNotExits     = errors.New("file not exists")
	ErrCannotHandleFile = errors.New("can not handle file")
	ErrNotImplemented   = errors.New("operation no implemented")
)

errors

Functions

func FileIsModified

func FileIsModified(handler FileResourceHandler, path string, etag string) (ok bool, err error)

FileIsModified 文件是否修改了

Types

type FileResourceHandler

type FileResourceHandler interface {
	CanHandle(path string) bool                                        // 是否可以处理此路径
	OpenForRead(path string) (io.ReadCloser, error)                    // 打开文件,得到reader
	CreateFile(path string, reader io.Reader) (etag string, err error) // 新建文件
	ContentLength(path string) (length int64, err error)               // 文件内容长度
	EntityTag(path string) (string, error)                             // 获取文件唯一标签
	IsModified(path string, etag string) (bool, error)                 // 是否修改了
}

FileResourceHandler 文件资源处理器接口

type HTTPFileResourceHandler

type HTTPFileResourceHandler struct{}

HTTPFileResourceHandler Http文件资源

func (*HTTPFileResourceHandler) CanHandle

func (h *HTTPFileResourceHandler) CanHandle(path string) bool

CanHandle 文件资源处理接口

func (*HTTPFileResourceHandler) ContentLength

func (h *HTTPFileResourceHandler) ContentLength(path string) (length int64, err error)

ContentLength 文件资源处理接口

func (*HTTPFileResourceHandler) CreateFile

func (h *HTTPFileResourceHandler) CreateFile(path string, reader io.Reader) (etag string, err error)

CreateFile 文件资源处理接口

func (*HTTPFileResourceHandler) EntityTag

func (h *HTTPFileResourceHandler) EntityTag(path string) (etag string, err error)

EntityTag 文件资源处理接口

func (*HTTPFileResourceHandler) IsModified

func (h *HTTPFileResourceHandler) IsModified(path string, etag string) (ok bool, err error)

IsModified 文件资源处理接口

func (*HTTPFileResourceHandler) OpenForRead

func (h *HTTPFileResourceHandler) OpenForRead(path string) (reader io.ReadCloser, err error)

OpenForRead 文件资源处理接口

type LocalFileResourceHandler

type LocalFileResourceHandler struct{}

LocalFileResourceHandler 本地文件资源

func (*LocalFileResourceHandler) CanHandle

func (h *LocalFileResourceHandler) CanHandle(path string) bool

CanHandle 文件资源处理接口

func (*LocalFileResourceHandler) ContentLength

func (h *LocalFileResourceHandler) ContentLength(path string) (length int64, err error)

ContentLength 文件资源处理接口

func (*LocalFileResourceHandler) CreateFile

func (h *LocalFileResourceHandler) CreateFile(filePath string, reader io.Reader) (etag string, err error)

CreateFile 文件资源处理接口

func (*LocalFileResourceHandler) EntityTag

func (h *LocalFileResourceHandler) EntityTag(path string) (etag string, err error)

EntityTag 文件资源处理接口

func (*LocalFileResourceHandler) IsModified

func (h *LocalFileResourceHandler) IsModified(path string, etag string) (ok bool, err error)

IsModified 文件资源处理接口

func (*LocalFileResourceHandler) OpenForRead

func (h *LocalFileResourceHandler) OpenForRead(path string) (reader io.ReadCloser, err error)

OpenForRead 文件资源处理接口

type MultiFileResourceHandler

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

MultiFileResourceHandler 多重文件资源处理器

func NewMultiFileResourceHandler

func NewMultiFileResourceHandler(handlers ...FileResourceHandler) (res *MultiFileResourceHandler)

NewMultiFileResourceHandler 新建多重文件资源处理器

func (*MultiFileResourceHandler) CanHandle

func (h *MultiFileResourceHandler) CanHandle(path string) bool

CanHandle 文件资源处理接口

func (*MultiFileResourceHandler) ContentLength

func (h *MultiFileResourceHandler) ContentLength(path string) (length int64, err error)

ContentLength 文件资源处理接口

func (*MultiFileResourceHandler) CreateFile

func (h *MultiFileResourceHandler) CreateFile(path string, reader io.Reader) (etag string, err error)

CreateFile 文件资源处理接口

func (*MultiFileResourceHandler) EntityTag

func (h *MultiFileResourceHandler) EntityTag(path string) (etag string, err error)

EntityTag 文件资源处理接口

func (*MultiFileResourceHandler) IsModified

func (h *MultiFileResourceHandler) IsModified(path string, etag string) (ok bool, err error)

IsModified 文件资源处理接口

func (*MultiFileResourceHandler) OpenForRead

func (h *MultiFileResourceHandler) OpenForRead(path string) (reader io.ReadCloser, err error)

OpenForRead 文件资源处理接口

func (*MultiFileResourceHandler) RegisterHandler

func (h *MultiFileResourceHandler) RegisterHandler(handler FileResourceHandler)

RegisterHandler 注册处理器

Jump to

Keyboard shortcuts

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