s3

package
v1.3.30 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataType

type DataType struct {
	AccessKey     string `json:"access_key"`      // 访问 S3 的密钥 ID
	SecretKey     string `json:"secret_key"`      // 访问 S3 的密钥
	Address       string `json:"address"`         // S3 服务的地址
	Ssl           bool   `json:"ssl"`             // 是否使用 SSL 加密连接
	Url           string `json:"url"`             // S3 服务的访问 URL
	BucketName    string `json:"bucket_name"`     // 默认存储桶名称
	BucketNameCdn string `json:"bucket_name_cdn"` // CDN 存储桶名称

}

DataType 定义了 S3 配置的数据结构,用于存储访问 S3 所需的各种信息

type Mod

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

Mod 定义了 S3 模块的结构体,包含一个 S3 客户端实例和配置信息

func New

func New(_name ...string) *Mod

New 根据配置创建一个新的 S3 模块实例 如果未提供名称,则从配置中获取默认的 S3 类型 配置错误时会触发 panic

func (*Mod) CopyObject

func (s *Mod) CopyObject(bucketName string, dstStr string, srcStr string) (err error)

CopyObject 在指定存储桶内复制文件 bucketName 存储桶名称 dstStr 目标文件路径 srcStr 源文件路径 返回操作过程中可能出现的错误

func (*Mod) GetCfg

func (s *Mod) GetCfg() *DataType

GetCfg 获取当前 S3 模块的配置信息

func (*Mod) GetFileUrl

func (s *Mod) GetFileUrl(name string, bucketName string, _expires ...time.Duration) (presignedURL *url.URL, err error)

GetFileUrl 生成指向 S3 存储桶中指定文件的预签名 URL 预签名 URL 可用于在有限时间内访问 S3 存储桶中的文件 支持从缓存中获取预签名 URL,以减少重复请求

func (*Mod) GetPath

func (s *Mod) GetPath(url string) (filePath string)

GetPath 从文件访问 URL 中提取文件路径

func (*Mod) GetUrl

func (s *Mod) GetUrl(filePath string, defaultFile ...string) (url string)

GetUrl 获取文件的访问地址 支持返回默认文件地址,根据 SSL 配置生成不同格式的 URL

func (*Mod) ListBuckets

func (s *Mod) ListBuckets() []minio.BucketInfo

ListBuckets 获取当前 S3 客户端可访问的所有存储桶列表 出错时返回 nil

func (*Mod) ListObjects

func (s *Mod) ListObjects(bucketName string, prefix string) (res <-chan minio.ObjectInfo, err error)

ListObjects 获取指定存储桶中指定前缀的文件列表 返回一个包含文件信息的通道

func (*Mod) PutFileUrl

func (s *Mod) PutFileUrl(name string, bucketName string) (presignedURL *url.URL, err error)

PutFileUrl 生成一个用于上传文件到指定存储桶的预签名 URL 预签名 URL 的有效期默认为 10 分钟

func (*Mod) PutObject

func (s *Mod) PutObject(f io.Reader, name string, bucketName string, _size ...int64) (res minio.UploadInfo, err error)

PutObject 上传文件到指定的存储桶中 支持指定文件大小,未指定时将读取文件直到结束

func (*Mod) RemoveObject

func (s *Mod) RemoveObject(name string, bucketName string) (err error)

RemoveObject 从指定存储桶中删除指定名称的文件 Deprecation: to新方法 RemoveObjectV2

func (*Mod) RemoveObjectV2 added in v1.2.36

func (s *Mod) RemoveObjectV2(bucketName string, name string) (err error)

RemoveObjectV2 从指定存储桶中删除指定名称的文件

func (*Mod) Rename added in v1.2.36

func (s *Mod) Rename(bucketName string, oldName string, newName string) (err error)

Rename 重命名文件

func (*Mod) SetBucketPolicy

func (s *Mod) SetBucketPolicy(bucketName string, prefix string) (err error)

SetBucketPolicy 设置指定存储桶或对象前缀的访问策略 目前使用固定的策略,可根据需求修改

func (*Mod) StatObject added in v1.2.56

func (s *Mod) StatObject(bucketName string, objectName string) (res minio.ObjectInfo, err error)

StatObject 获取指定存储桶中指定文件的元数据信息

Jump to

Keyboard shortcuts

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