uptoken

package
v7.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyBucketName 空的 Bucket 名称
	ErrEmptyBucketName = errors.New("empty bucket name")

	// ErrInvalidPolicyValue 非法凭证值
	ErrInvalidPolicyValue = errors.New("invalid put policy value")
)
View Source
var ErrInvalidUpToken = errors.New("invalid upToken")

ErrInvalidUpToken 非法的上传凭证

Functions

This section is empty.

Types

type AccessKeyProvider

type AccessKeyProvider interface {
	GetAccessKey(context.Context) (string, error)
}

AccessKeyProvider 获取 AccessKey 接口

type FieldError

type FieldError struct {
	Err error
}

FieldError indicates an error condition occurred while setting put policy

func (*FieldError) Error

func (e *FieldError) Error() string

func (*FieldError) Unwrap

func (e *FieldError) Unwrap() error

Unwrap returns the underlying error cause

type Provider

Provider 获取上传凭证,AccessKey 和上传策略接口

func NewParser

func NewParser(upToken string) Provider

NewParser 创建上传凭证签发器

func NewSigner

func NewSigner(putPolicy PutPolicy, credentialsProvider credentials.CredentialsProvider) Provider

NewSigner 创建上传凭证签发器

需要注意的是 NewSigner 仅仅只会通过 credentials.CredentialsProvider 获取一次鉴权参数,之后就会缓存该鉴权参数,不会反复获取

type PutPolicy

type PutPolicy map[string]interface{}

PutPolicy 存储上传策略

func NewPutPolicy

func NewPutPolicy(bucket string, expiry time.Time) (PutPolicy, error)

NewPutPolicy 为指定的空间生成上传策略

func NewPutPolicyWithKey

func NewPutPolicyWithKey(bucket, key string, expiry time.Time) (PutPolicy, error)

NewPutPolicyWithKey 为指定的空间和对象名称生成上传策略

func NewPutPolicyWithKeyPrefix

func NewPutPolicyWithKeyPrefix(bucket, keyPrefix string, expiry time.Time) (PutPolicy, error)

NewPutPolicyWithKeyPrefix 为指定的空间和对象前缀生成上传策略

func (PutPolicy) Delete

func (putPolicy PutPolicy) Delete(key string) (value interface{}, ok bool)

Delete 删除上传策略的值

func (PutPolicy) Get

func (putPolicy PutPolicy) Get(key string) (value interface{}, ok bool)

Get 获取上传策略的值

func (PutPolicy) GetBucketName

func (putPolicy PutPolicy) GetBucketName() (string, error)

GetBucketName 获取上传策略内的空间名称

该方法会从上传策略中解析出空间名称,如果上传策略中没有 scope 字段,则返回 ErrEmptyBucketName 错误,如果上传策略的 scope 字段格式有误,则返回 ErrInvalidPolicyValue 错误。

func (PutPolicy) GetCallbackBody

func (putPolicy PutPolicy) GetCallbackBody() (string, bool)

GetCallbackBody 获取上传成功后,七牛云向业务服务器发送 Content-Type: application/x-www-form-urlencoded 的 POST 请求

func (PutPolicy) GetCallbackBodyType

func (putPolicy PutPolicy) GetCallbackBodyType() (string, bool)

GetCallbackBodyType 获取上传成功后,七牛云向业务服务器发送回调通知 callbackBody 的 Content-Type

func (PutPolicy) GetCallbackHost

func (putPolicy PutPolicy) GetCallbackHost() (string, bool)

GetCallbackHost 获取上传成功后,七牛云向业务服务器发送回调通知时的 Host 值

func (PutPolicy) GetCallbackUrl

func (putPolicy PutPolicy) GetCallbackUrl() (string, bool)

GetCallbackUrl 获取上传成功后,七牛云向业务服务器发送 POST 请求的 URL

func (PutPolicy) GetDeadline

func (putPolicy PutPolicy) GetDeadline() (int64, bool)

GetDeadline 获取上传策略有效截止时间

func (PutPolicy) GetDetectMime

func (putPolicy PutPolicy) GetDetectMime() (int64, bool)

GetDetectMime 获取开启 MimeType 侦测功能

func (PutPolicy) GetEndUser

func (putPolicy PutPolicy) GetEndUser() (string, bool)

GetEndUser 获取唯一属主标识

func (PutPolicy) GetFileType

func (putPolicy PutPolicy) GetFileType() (int64, bool)

GetFileType 获取文件存储类型

func (PutPolicy) GetForceSaveKey

func (putPolicy PutPolicy) GetForceSaveKey() (bool, bool)

GetForceSaveKey 获取 saveKey 的优先级设置

func (PutPolicy) GetFsizeLimit

func (putPolicy PutPolicy) GetFsizeLimit() (int64, bool)

GetFsizeLimit 获取限定上传文件大小最大值

func (PutPolicy) GetFsizeMin

func (putPolicy PutPolicy) GetFsizeMin() (int64, bool)

GetFsizeMin 获取限定上传文件大小最小值

func (PutPolicy) GetInsertOnly

func (putPolicy PutPolicy) GetInsertOnly() (int64, bool)

GetInsertOnly 获取是否限定为新增语意

func (PutPolicy) GetIsPrefixalScope

func (putPolicy PutPolicy) GetIsPrefixalScope() (int64, bool)

GetIsPrefixalScope 获取是否允许用户上传以 scope 的 keyPrefix 为前缀的文件

func (PutPolicy) GetMimeLimit

func (putPolicy PutPolicy) GetMimeLimit() (string, bool)

GetMimeLimit 获取限定用户上传的文件类型

func (PutPolicy) GetPersistentNotifyUrl

func (putPolicy PutPolicy) GetPersistentNotifyUrl() (string, bool)

GetPersistentNotifyUrl 获取接收持久化处理结果通知的 URL

func (PutPolicy) GetPersistentOps

func (putPolicy PutPolicy) GetPersistentOps() (string, bool)

GetPersistentOps 获取资源上传成功后触发执行的预转持久化处理指令列表

func (PutPolicy) GetPersistentPipeline

func (putPolicy PutPolicy) GetPersistentPipeline() (string, bool)

GetPersistentPipeline 获取转码队列名

func (PutPolicy) GetPersistentType added in v7.23.0

func (putPolicy PutPolicy) GetPersistentType() (int64, bool)

GetPersistentType 获取任务类型

func (PutPolicy) GetPersistentWorkflowTemplateID added in v7.24.0

func (putPolicy PutPolicy) GetPersistentWorkflowTemplateID() (string, bool)

GetPersistentWorkflowTemplateID 获取工作流模版 ID

func (PutPolicy) GetReturnBody

func (putPolicy PutPolicy) GetReturnBody() (string, bool)

GetReturnBody 获取上传成功后,自定义七牛云最终返回给上传端的数据

func (PutPolicy) GetReturnUrl

func (putPolicy PutPolicy) GetReturnUrl() (string, bool)

GetReturnUrl 获取 Web 端文件上传成功后,浏览器执行 303 跳转的 URL

func (PutPolicy) GetSaveKey

func (putPolicy PutPolicy) GetSaveKey() (string, bool)

GetSaveKey 获取自定义资源名

func (PutPolicy) GetScope

func (putPolicy PutPolicy) GetScope() (string, bool)

GetScope 获取指定的上传的目标资源空间 Bucket 和资源键 Key

func (PutPolicy) Set

func (putPolicy PutPolicy) Set(key string, value interface{}) error

Set 设置上传策略的值

如果 value 为 nil,则返回 ErrInvalidPolicyValue 错误。

func (PutPolicy) SetCallbackBody

func (putPolicy PutPolicy) SetCallbackBody(value string) PutPolicy

SetCallbackBody 指定上传成功后,七牛云向业务服务器发送 Content-Type: application/x-www-form-urlencoded 的 POST 请求

func (PutPolicy) SetCallbackBodyType

func (putPolicy PutPolicy) SetCallbackBodyType(value string) PutPolicy

SetCallbackBodyType 指定上传成功后,七牛云向业务服务器发送回调通知 callbackBody 的 Content-Type

func (PutPolicy) SetCallbackHost

func (putPolicy PutPolicy) SetCallbackHost(value string) PutPolicy

SetCallbackHost 指定上传成功后,七牛云向业务服务器发送回调通知时的 Host 值

func (PutPolicy) SetCallbackUrl

func (putPolicy PutPolicy) SetCallbackUrl(value string) PutPolicy

SetCallbackUrl 指定上传成功后,七牛云向业务服务器发送 POST 请求的 URL

func (PutPolicy) SetDeadline

func (putPolicy PutPolicy) SetDeadline(value int64) PutPolicy

SetDeadline 指定上传策略有效截止时间

func (PutPolicy) SetDetectMime

func (putPolicy PutPolicy) SetDetectMime(value int64) PutPolicy

SetDetectMime 指定开启 MimeType 侦测功能

func (PutPolicy) SetEndUser

func (putPolicy PutPolicy) SetEndUser(value string) PutPolicy

SetEndUser 指定唯一属主标识

func (PutPolicy) SetFileType

func (putPolicy PutPolicy) SetFileType(value int64) PutPolicy

SetFileType 指定文件存储类型

func (PutPolicy) SetForceSaveKey

func (putPolicy PutPolicy) SetForceSaveKey(value bool) PutPolicy

SetForceSaveKey 指定 saveKey 的优先级设置

func (PutPolicy) SetFsizeLimit

func (putPolicy PutPolicy) SetFsizeLimit(value int64) PutPolicy

SetFsizeLimit 指定限定上传文件大小最大值

func (PutPolicy) SetFsizeMin

func (putPolicy PutPolicy) SetFsizeMin(value int64) PutPolicy

SetFsizeMin 指定限定上传文件大小最小值

func (PutPolicy) SetInsertOnly

func (putPolicy PutPolicy) SetInsertOnly(value int64) PutPolicy

SetInsertOnly 指定是否限定为新增语意

func (PutPolicy) SetIsPrefixalScope

func (putPolicy PutPolicy) SetIsPrefixalScope(value int64) PutPolicy

SetIsPrefixalScope 指定是否允许用户上传以 scope 的 keyPrefix 为前缀的文件

func (PutPolicy) SetMimeLimit

func (putPolicy PutPolicy) SetMimeLimit(value string) PutPolicy

SetMimeLimit 指定限定用户上传的文件类型

func (PutPolicy) SetPersistentNotifyUrl

func (putPolicy PutPolicy) SetPersistentNotifyUrl(value string) PutPolicy

SetPersistentNotifyUrl 指定接收持久化处理结果通知的 URL

func (PutPolicy) SetPersistentOps

func (putPolicy PutPolicy) SetPersistentOps(value string) PutPolicy

SetPersistentOps 指定资源上传成功后触发执行的预转持久化处理指令列表

func (PutPolicy) SetPersistentPipeline

func (putPolicy PutPolicy) SetPersistentPipeline(value string) PutPolicy

SetPersistentPipeline 指定转码队列名

func (PutPolicy) SetPersistentType added in v7.23.0

func (putPolicy PutPolicy) SetPersistentType(value int64) PutPolicy

SetPersistentType 指定任务类型

func (PutPolicy) SetPersistentWorkflowTemplateID added in v7.24.0

func (putPolicy PutPolicy) SetPersistentWorkflowTemplateID(value string) PutPolicy

SetPersistentWorkflowTemplateID 指定工作流模版 ID

func (PutPolicy) SetReturnBody

func (putPolicy PutPolicy) SetReturnBody(value string) PutPolicy

SetReturnBody 指定上传成功后,自定义七牛云最终返回给上传端的数据

func (PutPolicy) SetReturnUrl

func (putPolicy PutPolicy) SetReturnUrl(value string) PutPolicy

SetReturnUrl 指定 Web 端文件上传成功后,浏览器执行 303 跳转的 URL

func (PutPolicy) SetSaveKey

func (putPolicy PutPolicy) SetSaveKey(value string) PutPolicy

SetSaveKey 指定自定义资源名

func (PutPolicy) SetScope

func (putPolicy PutPolicy) SetScope(value string) PutPolicy

SetScope 指定上传的目标资源空间 Bucket 和资源键 Key

type PutPolicyProvider

type PutPolicyProvider interface {
	GetPutPolicy(context.Context) (PutPolicy, error)
}

PutPolicyProvider 获取上传策略接口

type UpTokenProvider

type UpTokenProvider interface {
	GetUpToken(context.Context) (string, error)
}

UpTokenProvider 获取上传凭证接口

Jump to

Keyboard shortcuts

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