uploader

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Uploader

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

Uploader 包装 s3manager,提供单文件/目录上传。 s3 字段声明为 manager.UploadAPIClient 接口(而非具体 *s3.Client), 使上传路径可在测试中用 mock 覆盖;真实客户端天然满足该接口。

func New

func New(s3c *s3.Client) *Uploader

func (*Uploader) UploadDir

func (u *Uploader) UploadDir(ctx context.Context, localDir, bucket, prefix, contentType string) error

UploadDir 递归上传本地目录到 bucket 下的 prefix。contentType 非空时应用到 目录内全部文件,为空则逐文件各自判定。

func (*Uploader) UploadFile

func (u *Uploader) UploadFile(ctx context.Context, localPath, bucket, key, contentType string) error

UploadFile 上传单个本地文件到 bucket/key。contentType 为空时自动判定 (目标 key → 本地文件名 → 内容嗅探 → application/octet-stream)。

func (*Uploader) UploadStream

func (u *Uploader) UploadStream(ctx context.Context, r io.Reader, bucket, key, contentType string) error

UploadStream 从 reader 读取全部内容上传为单个 object。 s3manager 要求可 seek 的 reader,管道/网络流不可 seek, 因此先读入内存 buffer 再上传。contentType 语义同 UploadFile。

Jump to

Keyboard shortcuts

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