provider

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider 是厂商知识的唯一入口:白名单、(provider, region) → 行为表、

Index

Constants

View Source
const (
	AWS   = "aws"   // AWS S3
	BOS   = "bos"   // 百度云 BOS
	OSS   = "oss"   // 阿里云 OSS
	COS   = "cos"   // 腾讯云 COS
	OBS   = "obs"   // 华为云 OBS
	MINIO = "minio" // MinIO(自建,S3 兼容)
	USS   = "uss"   // UCloud US3
)

厂商标识:store.provider 的合法取值,即代码里的白名单。

View Source
const (
	AddressingPath  = "path"  // 路径寻址:{endpoint}/{bucket}/{key}
	AddressingVhost = "vhost" // 虚拟主机寻址:{bucket}.{endpoint}/{key}
)

寻址方式

Variables

View Source
var (
	// ErrUnknownProvider provider 不在白名单内
	ErrUnknownProvider = errors.New("provider: 不在白名单内")
	// ErrNotImplemented provider 在白名单内但行为表未实现
	ErrNotImplemented = errors.New("provider: 行为表未实现")
	// ErrInvalidEndpoint endpoint 为空或非法
	ErrInvalidEndpoint = errors.New("provider: endpoint 为空或非法")
	// ErrEndpointMismatch host 不匹配该 provider 的域名族
	ErrEndpointMismatch = errors.New("provider: endpoint 不匹配该 provider 的域名族")
)

Functions

func AddressingStyle

func AddressingStyle(p, region string) (string, error)

AddressingStyle 推导寻址方式:按 provider 默认,命中 vhost-only 区域白名单则强制 vhost。

func CanonicalBaseURL

func CanonicalBaseURL(u string) string

CanonicalBaseURL 归一化公网访问地址前缀:去首尾空白与尾斜杠。

func CanonicalEndpoint

func CanonicalEndpoint(p, endpoint string) (string, error)

CanonicalEndpoint 归一化 endpoint 到该 provider 的规范形态(不归一化会让同一物理桶出现两行)。

func HostOf

func HostOf(u string) string

HostOf 从 URL 或裸域名中取出小写 host(去空白、去 scheme、去 path/query/fragment)。

func Implemented

func Implemented(p string) bool

Implemented 判断 provider 的行为表是否已实现。

func Known

func Known(p string) bool

Known 判断 provider 是否在白名单内。

func NormalizeRegion

func NormalizeRegion(p, region string) string

NormalizeRegion 归一化区域:剥掉 {provider}- / s3- 前缀(容错把端点主机名前缀当 region 的情况)。 例:oss-cn-beijing → cn-beijing、cos-ap-guangzhou → ap-guangzhou;无已知前缀原样返回。

func PartETagIsContentMD5

func PartETagIsContentMD5(p string) bool

PartETagIsContentMD5 判断该 provider 的分片 ETag 是否等于分片内容 MD5(未开服务端加密时成立)。

Types

type Provider

type Provider struct {
	Value       string // 写进 store.provider 的字面量
	Label       string // 展示名
	Implemented bool   // 行为表是否已实现(false 让前端置灰,而不是让用户选完再被拒)
}

Provider 厂商描述

func List

func List() []Provider

List 返回代码里已注册的厂商清单(顺序固定),implemented 由行为表推导。

Jump to

Keyboard shortcuts

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