Documentation
¶
Index ¶
- type R2Client
- func (r *R2Client) DeleteObject(ctx context.Context, objectKey string) error
- func (r *R2Client) GeneratePresignedURL(ctx context.Context, objectKey string, expires time.Duration) (string, error)
- func (r *R2Client) ListObjects(ctx context.Context, prefix string, maxKeys int32) ([]string, error)
- func (r *R2Client) UploadAny(ctx context.Context, source interface{}, objectKey string, contentType string) (*UploadResult, error)
- func (r *R2Client) UploadBytes(ctx context.Context, data []byte, objectKey string, contentType string) (*UploadResult, error)
- func (r *R2Client) UploadData(ctx context.Context, reader io.Reader, objectKey string, contentType string, ...) (*UploadResult, error)
- func (r *R2Client) UploadFile(ctx context.Context, filePath string, objectKey string, contentType string) (*UploadResult, error)
- func (r *R2Client) UploadMultipartFile(ctx context.Context, file *multipart.FileHeader, objectKey string, ...) (*UploadResult, error)
- func (r *R2Client) UploadReader(ctx context.Context, reader io.Reader, objectKey string, contentType string, ...) (*UploadResult, error)
- type R2Config
- type UploadResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type R2Client ¶
type R2Client struct {
// contains filtered or unexported fields
}
R2Client 处理 Cloudflare R2 的文件上传
func NewR2Client ¶
NewR2Client 使用提供的配置创建一个新的 R2Client
func (*R2Client) DeleteObject ¶
DeleteObject 从 R2 删除对象
func (*R2Client) GeneratePresignedURL ¶
func (r *R2Client) GeneratePresignedURL(ctx context.Context, objectKey string, expires time.Duration) (string, error)
GeneratePresignedURL 为对象生成预签名 URL
func (*R2Client) ListObjects ¶
ListObjects 列出存储桶中具有给定前缀的对象
func (*R2Client) UploadAny ¶
func (r *R2Client) UploadAny(ctx context.Context, source interface{}, objectKey string, contentType string) (*UploadResult, error)
UploadAny 是一个通用的上传方法,可以处理各种类型的输入 支持: 文件路径(string), []byte, io.Reader, *multipart.FileHeader
func (*R2Client) UploadBytes ¶
func (r *R2Client) UploadBytes(ctx context.Context, data []byte, objectKey string, contentType string) (*UploadResult, error)
UploadBytes 上传字节数组到 R2
func (*R2Client) UploadData ¶
func (r *R2Client) UploadData(ctx context.Context, reader io.Reader, objectKey string, contentType string, size int64) (*UploadResult, error)
UploadData 从 io.Reader 上传数据到 R2
func (*R2Client) UploadFile ¶
func (r *R2Client) UploadFile(ctx context.Context, filePath string, objectKey string, contentType string) (*UploadResult, error)
UploadFile 从本地文件路径上传文件到 R2
func (*R2Client) UploadMultipartFile ¶
func (r *R2Client) UploadMultipartFile(ctx context.Context, file *multipart.FileHeader, objectKey string, contentType string) (*UploadResult, error)
UploadMultipartFile 上传 multipart 文件到 R2
Click to show internal directories.
Click to hide internal directories.