base

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceOss = "oss"

	Qiniu  = "qiniu"
	Huawei = "huawei"
	S3     = "s3"
	MINIO  = "minio"
)
View Source
const (
	ServiceResource = "resource"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseOss

type BaseOss struct {
	IOss

	Endpoints map[string]Endpoint
}

func (*BaseOss) AddEndpoint

func (s *BaseOss) AddEndpoint(name string, endpoint Endpoint)

func (*BaseOss) GetEndpoint

func (s *BaseOss) GetEndpoint(name string) (*Endpoint, error)

func (*BaseOss) GetObject

func (s *BaseOss) GetObject(endpoint string, key string) ([]byte, error)

func (*BaseOss) Init

func (s *BaseOss) Init()

func (*BaseOss) ListObjects

func (s *BaseOss) ListObjects(endpoint string, prefix string, token string) ([]string, string, error)

func (*BaseOss) UploadFromFile added in v0.1.16

func (s *BaseOss) UploadFromFile(endpoint string, key string, filepath string, opt ...interface{}) error

type Endpoint

type Endpoint struct {
	Provider string `yaml:"provider"`
	AppID    string `yaml:"appid"`
	Secret   string `yaml:"secret"`
	Bucket   string `yaml:"bucket"`
	SSL      bool   `yaml:"ssl"`
	Zone     string `yaml:"zone"`

	// 终端节点, 用于华为云obs
	Endpoint string `yaml:"endpoint"`
}

type IOss

type IOss interface {
	Init()
	Upload(endpoint string, key string, data []byte, opt ...interface{}) error
	UploadFromFile(endpoint string, key string, filepath string, opt ...interface{}) error
	Delete(endpoint string, key string) error
	ListObjects(endpoint string, prefix string, token string) ([]string, string, error)
	GetEndpoint(name string) (*Endpoint, error)
	AddEndpoint(name string, endpoint Endpoint)
	GetObject(endpoint string, key string) ([]byte, error)
}

type IServiceOss

type IServiceOss interface {
	Upload(endpoint string, key string, data []byte, opt ...interface{}) error
	UploadFromFile(endpoint string, key string, filepath string, opt ...interface{}) error
	Delete(endpoint string, key string) error
	ListObjects(endpoint string, prefix string, token string) ([]string, string, error)
	GetObject(endpoint string, key string) ([]byte, error)
	GetConfig() map[string]Endpoint
}

type IServiceResource

type IServiceResource interface {
	CreateResources(resources []*Resource) error
	RemoveResourcesByIDs(ids []string) error
	GetResourcesByIDs(ids []string) ([]*Resource, error)
	GetResourcesByObjectID(objectID string) ([]*Resource, error)
	SetOssEndpoint(endpoint string)
	GetResourceUrl() string
}

type ReqBatchDownload

type ReqBatchDownload struct {
	FileName string
	Key      string
}

type Resource

type Resource struct {
	sptty.SimpleModelBase

	ObjectID string `gorm:"size:32" json:"-"`
	Name     string `json:"-"`
	Mime     string `json:"mime"`
	Tag      string `gorm:"size:32" json:"tag"`
	Size     uint64 `json:"size"`

	Data    []byte `gorm:"-" json:"-"`
	NameUrl string `gorm:"-" json:"name"`
}

func GetResourcesFromRequestForm

func GetResourcesFromRequestForm(ctx iris.Context) ([]*Resource, error)

func SerializeResources

func SerializeResources(resources []*Resource, resUrl string) []*Resource

func (*Resource) Serialize

func (s *Resource) Serialize(resUrl string) *Resource

Jump to

Keyboard shortcuts

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