xobj

package module
v0.0.0-...-c285e0e Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProviderCOS = "cos"
)

ProviderCOS provider tencent cloud cos

Variables

View Source
var ErrorMissingKey = xerr.Newf(400, "MissingKey", "key is required")

Functions

This section is empty.

Types

type Client

type Client interface {
	// Group can auto add prefix to key
	Group(prefix string) Client
	// Prefix show group prefix
	Prefix() string
	// FullKey add prefix to key
	FullKey(key string) string
	// GetRaw get raw http resp
	GetRaw(key string) (*http.Response, error)
	// GetReader please close it after use
	GetReader(key string) (io.ReadCloser, error)
	// Get get file byte content only
	Get(key string) ([]byte, error)
	// Exists exists or not
	Exists(key string) (bool, error)
	// Put please close reader yourself, key is required, default content type is application/octet-stream
	Put(r io.Reader, key, name, contentType string) error
	// PutRaw put the raw data without any meta, you can only use it by api.
	PutRaw(r io.Reader, key string) error
	// PutURL save the src online file to key
	PutURL(src, key string) error
	// Delete delete
	Delete(key string) error
	// IsNotFoundError check not found err
	IsNotFoundError(err error) bool
}

Client is obj client interface

func New

func New(config Config) Client

New create a client

type Config

type Config struct {
	Provider string `default:"cos"`
	Cos      CosConfig
}

Config you can choose a provider and omit others

type CosConfig

type CosConfig struct {
	AppID     string
	Region    string
	SecretID  string
	SecretKey string
	Bucket    string
	Prefix    string
}

Jump to

Keyboard shortcuts

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