r2

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

* @Author: kamalyes 501893067@qq.com * @Date: 2026-04-23 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2026-04-23 00:00:00 * @FilePath: \go-toolbox\pkg\ossx\adapter\r2\r2.go * @Description: Cloudflare R2 Worker 对象存储适配器 * * 通过 Cloudflare Worker 代理访问 R2 存储 * 使用 AES-CBC-PKCS7 加密签名保证安全性 * 仅支持:预签名上传地址、上传对象(其他操作通过 Worker API 扩展) * * Copyright (c) 2026 by kamalyes, All Rights Reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter R2 Worker 存储适配器

func NewAdapter

func NewAdapter(cfg *Config) (*Adapter, error)

NewAdapter 创建 R2 Worker 适配器

func (*Adapter) BucketExists

func (a *Adapter) BucketExists(ctx context.Context, bucketName string) (bool, error)

BucketExists 判断存储桶是否存在(R2 Worker 不支持)

func (*Adapter) DeleteObject

func (a *Adapter) DeleteObject(ctx context.Context, bucketName, objectKey string) error

DeleteObject 删除对象(R2 Worker 不支持)

func (*Adapter) GetObject

func (a *Adapter) GetObject(ctx context.Context, bucketName, objectKey string) (*ossx.ObjectInfo, error)

GetObject 获取对象元信息(R2 Worker 有限支持)

func (*Adapter) GetObjectBlob

func (a *Adapter) GetObjectBlob(ctx context.Context, bucketName, objectKey string) ([]byte, error)

GetObjectBlob 获取对象二进制内容(R2 Worker 不支持)

func (*Adapter) IsConnected

func (a *Adapter) IsConnected() bool

IsConnected 检查 R2 Worker 是否可用

func (*Adapter) ListObjects

func (a *Adapter) ListObjects(ctx context.Context, bucketName, prefix string, limit int) ([]ossx.ObjectInfo, string, error)

ListObjects 列举对象(R2 Worker 不支持)

func (*Adapter) PresignedDownloadURL

func (a *Adapter) PresignedDownloadURL(ctx context.Context, bucketName, objectKey string, expiry time.Duration) (*ossx.PresignedResult, error)

PresignedDownloadURL 生成预签名下载地址(R2 Worker 不支持)

func (*Adapter) PresignedUploadURL

func (a *Adapter) PresignedUploadURL(ctx context.Context, bucketName, objectKey string, expiry time.Duration) (*ossx.PresignedResult, error)

PresignedUploadURL 生成预签名上传地址

func (*Adapter) Provider

func (a *Adapter) Provider() ossx.ProviderType

Provider 返回存储提供商类型

func (*Adapter) PutObject

func (a *Adapter) PutObject(ctx context.Context, bucketName, objectKey string, data io.Reader, size int64, contentType string) (*ossx.ObjectInfo, error)

PutObject 上传对象到 R2

type Config

type Config struct {
	Endpoint string // Worker 代理端点地址
	Key      string // AES 加密密钥(32 字节)
	IV       string // AES 初始化向量(16 字节)
}

Config R2 Worker 适配器配置

Jump to

Keyboard shortcuts

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