filesystem

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMultipartStream

func ReadMultipartStream(file *multipart.FileHeader) ([]byte, error)

Types

type CosFilesystem

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

func NewCosFilesystem

func NewCosFilesystem(conf *config.Config) *CosFilesystem

NewCosFilesystem ... See: https://cloud.tencent.com/document/product/436/31215

func (*CosFilesystem) Append

func (c *CosFilesystem) Append(filePath string)

func (*CosFilesystem) CompleteMultipartUpload

func (c *CosFilesystem) CompleteMultipartUpload(filePath string, uploadID string, opt *cos.CompleteMultipartUploadOptions) error

func (*CosFilesystem) Copy

func (c *CosFilesystem) Copy(srcPath, filePath string) error

Copy 文件拷贝

func (*CosFilesystem) CreateDir

func (c *CosFilesystem) CreateDir(path string) error

CreateDir 递归创建文件夹

func (*CosFilesystem) Delete

func (c *CosFilesystem) Delete(filePath string) error

Delete 删除一个文件或空文件夹

func (*CosFilesystem) DeleteDir

func (c *CosFilesystem) DeleteDir(path string) error

DeleteDir 删除文件夹

func (*CosFilesystem) InitiateMultipartUpload

func (c *CosFilesystem) InitiateMultipartUpload(filePath string, fileName string) (string, error)

func (*CosFilesystem) PrivateUrl

func (c *CosFilesystem) PrivateUrl(filePath string, timeout time.Duration) string

func (*CosFilesystem) PublicUrl

func (c *CosFilesystem) PublicUrl(filePath string) string

func (*CosFilesystem) ReadStream

func (c *CosFilesystem) ReadStream(filePath string) ([]byte, error)

ReadStream 读取文件流信息

func (*CosFilesystem) Stat

func (c *CosFilesystem) Stat(filePath string) (*FileStat, error)

Stat 文件信息

func (*CosFilesystem) UploadPart

func (c *CosFilesystem) UploadPart(filePath string, uploadID string, num int, stream []byte) (string, error)

func (*CosFilesystem) Write

func (c *CosFilesystem) Write(data []byte, filePath string) error

Write 文件写入

func (*CosFilesystem) WriteFromFile

func (c *CosFilesystem) WriteFromFile(file *multipart.FileHeader, filePath string) error

func (*CosFilesystem) WriteLocal

func (c *CosFilesystem) WriteLocal(localFile string, filePath string) error

WriteLocal 本地文件上传

type FileStat

type FileStat struct {
	Name        string    // 文件名
	Size        int64     // 文件大小
	Ext         string    // 文件后缀
	LastModTime time.Time // 最后修改时间
	MimeType    string    // 媒体类型
}

FileStat 文件信息

type Filesystem

type Filesystem struct {
	Default IAdapter
	Local   *LocalFilesystem
	Cos     *CosFilesystem
	// contains filtered or unexported fields
}

func NewFilesystem

func NewFilesystem(conf *config.Config) *Filesystem

func (*Filesystem) Driver

func (f *Filesystem) Driver() string

func (*Filesystem) SetDriver

func (f *Filesystem) SetDriver(value string)

type IAdapter

type IAdapter interface {
	// Write 文件写入
	Write(data []byte, filePath string) error

	// WriteLocal 本地文件上传
	WriteLocal(localFile string, filePath string) error

	// Copy 文件拷贝
	Copy(srcPath, filePath string) error

	// Delete 删除一个文件或空文件夹
	Delete(filePath string) error

	// DeleteDir 删除文件夹
	DeleteDir(path string) error

	// CreateDir 递归创建文件夹
	CreateDir(path string) error

	// Stat 文件信息
	Stat(filePath string) (*FileStat, error)

	// PublicUrl 获取公开文件的访问地址
	PublicUrl(filePath string) string

	// PrivateUrl 获取私有文件的访问地址
	PrivateUrl(filePath string, timeout time.Duration) string

	// ReadStream 读取文件内容
	ReadStream(filePath string) ([]byte, error)

	InitiateMultipartUpload(filePath string, fileName string) (string, error)
}

type LocalFilesystem

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

func NewLocalFilesystem

func NewLocalFilesystem(conf *config.Config) *LocalFilesystem

func (*LocalFilesystem) AppendWrite

func (s *LocalFilesystem) AppendWrite(data []byte, filePath string) error

func (*LocalFilesystem) Copy

func (s *LocalFilesystem) Copy(srcPath, filePath string) error

Copy 文件拷贝

func (*LocalFilesystem) CreateDir

func (s *LocalFilesystem) CreateDir(dir string) error

CreateDir 递归创建文件夹

func (*LocalFilesystem) Delete

func (s *LocalFilesystem) Delete(filePath string) error

Delete 文件删除

func (*LocalFilesystem) DeleteDir

func (s *LocalFilesystem) DeleteDir(dir string) error

DeleteDir 删除文件夹

func (*LocalFilesystem) InitiateMultipartUpload

func (s *LocalFilesystem) InitiateMultipartUpload(_ string, _ string) (string, error)

func (*LocalFilesystem) Path

func (s *LocalFilesystem) Path(path string) string

Path 获取文件地址绝对路径

func (*LocalFilesystem) PrivateUrl

func (s *LocalFilesystem) PrivateUrl(filePath string, timeout time.Duration) string

PrivateUrl 获取私有URL

func (*LocalFilesystem) PublicUrl

func (s *LocalFilesystem) PublicUrl(filePath string) string

PublicUrl 获取公共URL

func (*LocalFilesystem) ReadStream

func (s *LocalFilesystem) ReadStream(filePath string) ([]byte, error)

ReadStream 读取文件流

func (*LocalFilesystem) Stat

func (s *LocalFilesystem) Stat(filePath string) (*FileStat, error)

Stat 文件信息

func (*LocalFilesystem) Write

func (s *LocalFilesystem) Write(data []byte, filePath string) error

Write 上传 Byte 数组

func (*LocalFilesystem) WriteLocal

func (s *LocalFilesystem) WriteLocal(localFile string, filePath string) error

WriteLocal 本地文件上传

Jump to

Keyboard shortcuts

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