storage

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Local

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

func (*Local) Delete

func (l *Local) Delete(files ...string) error

Delete 删除文件

func (*Local) Exists

func (l *Local) Exists(file string) bool

Exists 检查文件是否存在

func (*Local) LastModified

func (l *Local) LastModified(file string) (time.Time, error)

LastModified 获取文件最后修改时间

func (*Local) List

func (l *Local) List(path string) ([]string, error)

List 列出目录下的所有文件

func (*Local) Put

func (l *Local) Put(file string, content io.Reader) error

Put 写入文件内容

func (*Local) Size

func (l *Local) Size(file string) (int64, error)

Size 获取文件大小

type S3

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

func (*S3) Delete

func (s *S3) Delete(files ...string) error

Delete 删除文件

func (*S3) Exists

func (s *S3) Exists(file string) bool

Exists 检查文件是否存在

func (*S3) LastModified

func (s *S3) LastModified(file string) (time.Time, error)

LastModified 获取文件最后修改时间

func (*S3) List

func (s *S3) List(path string) ([]string, error)

List 列出目录下的所有文件

func (*S3) Put

func (s *S3) Put(file string, content io.Reader) error

Put 写入文件内容

func (*S3) Size

func (s *S3) Size(file string) (int64, error)

Size 获取文件大小

type S3AddressingStyle

type S3AddressingStyle string

S3AddressingStyle S3 地址模式

const (
	// S3AddressingStylePath Path 模式:https://s3.region.amazonaws.com/bucket/key
	S3AddressingStylePath S3AddressingStyle = "path"
	// S3AddressingStyleVirtualHosted Virtual Hosted 模式:https://bucket.s3.region.amazonaws.com/key
	S3AddressingStyleVirtualHosted S3AddressingStyle = "virtual-hosted"
)

type S3Config

type S3Config struct {
	Region          string            // AWS 区域
	Bucket          string            // S3 存储桶名称
	AccessKey       string            // 访问密钥 ID
	SecretKey       string            // 访问密钥
	Endpoint        string            // 自定义端点
	Scheme          string            // 协议 http 或 https
	BasePath        string            // 基础路径前缀
	AddressingStyle S3AddressingStyle // 地址模式
}

type SFTP

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

func (*SFTP) Delete

func (s *SFTP) Delete(files ...string) error

Delete 删除文件

func (*SFTP) Exists

func (s *SFTP) Exists(file string) bool

Exists 检查文件是否存在

func (*SFTP) LastModified

func (s *SFTP) LastModified(file string) (time.Time, error)

LastModified 获取文件最后修改时间

func (*SFTP) List

func (s *SFTP) List(path string) ([]string, error)

List 列出目录下的所有文件

func (*SFTP) Put

func (s *SFTP) Put(file string, content io.Reader) error

Put 写入文件内容

func (*SFTP) Size

func (s *SFTP) Size(file string) (int64, error)

Size 获取文件大小

type SFTPConfig

type SFTPConfig struct {
	Host       string        // SFTP 服务器地址
	Port       int           // SFTP 端口,默认 22
	Username   string        // 用户名
	Password   string        // 密码
	PrivateKey string        // SSH 私钥
	BasePath   string        // 基础路径
	Timeout    time.Duration // 连接超时时间
}

type Storage

type Storage interface {
	// Delete deletes the given file(s).
	Delete(file ...string) error
	// Exists determines if a file exists.
	Exists(file string) bool
	// LastModified gets the file's last modified time.
	LastModified(file string) (time.Time, error)
	// List lists all files (not directories) in the given path.
	List(path string) ([]string, error)
	// Put writes the contents of a file.
	Put(file string, content io.Reader) error
	// Size gets the file size of a given file.
	Size(file string) (int64, error)
}

func NewLocal

func NewLocal(basePath string) (Storage, error)

func NewS3

func NewS3(cfg S3Config) (Storage, error)

func NewSFTP

func NewSFTP(config SFTPConfig) (Storage, error)

func NewWebDav

func NewWebDav(config WebDavConfig) (Storage, error)

type WebDav

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

func (*WebDav) Delete

func (w *WebDav) Delete(files ...string) error

Delete 删除文件

func (*WebDav) Exists

func (w *WebDav) Exists(file string) bool

Exists 检查文件是否存在

func (*WebDav) LastModified

func (w *WebDav) LastModified(file string) (time.Time, error)

LastModified 获取文件最后修改时间

func (*WebDav) List

func (w *WebDav) List(path string) ([]string, error)

List 列出目录下的所有文件

func (*WebDav) Put

func (w *WebDav) Put(file string, content io.Reader) error

Put 写入文件内容

func (*WebDav) Size

func (w *WebDav) Size(file string) (int64, error)

Size 获取文件大小

type WebDavConfig

type WebDavConfig struct {
	URL      string        // WebDAV 服务器 URL
	Username string        // 用户名
	Password string        // 密码
	BasePath string        // 基础路径
	Timeout  time.Duration // 连接超时时间
}

Jump to

Keyboard shortcuts

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