storage

package
v0.0.0-...-2f28ce4 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(filepath string) []byte

文件读取

Types

type Aliyun

type Aliyun struct {
	AccessKeyId     string `mapstructure:"AccessKeyId"`
	AccessKeySecret string `mapstructure:"AccessKeySecret"`
	Endpoint        string `mapstructure:"Endpoint"`
	BucketName      string `mapstructure:"BucketName"`
	Root            string `mapstructure:"Root"`
	Domain          string `mapstructure:"Domain"`
	Bucket          *oss.Bucket
}

阿里云OOS配置

func (*Aliyun) Client

func (aliyun *Aliyun) Client() *Aliyun

实例化客户端

func (Aliyun) DownloadLocalFile

func (aliyun Aliyun) DownloadLocalFile(objectKey, tempFile string) (err error)

下载文件至指定位置 @param objectKey string 对象文件 @param tempFile 临时文件 @return error

func (Aliyun) UploadLoclFile

func (aliyun Aliyun) UploadLoclFile(savePath, filePath string) (objectKey string, domain string, err error)

上传本地文件 @param root string 保存至目录 @param filePath 本地文件路径 @return string,error

type Aws

type Aws struct {
	AccessKeyId     string `mapstructure:"AccessKeyId"`
	SecretAccesskey string `mapstructure:"SecretAccesskey"`
	Region          string `mapstructure:"Region"`
	Bucket          string `mapstructure:"Bucket"`
	Version         string `mapstructure:"Version"`
	Root            string `mapstructure:"Root"`
	Domain          string `mapstructure:"Domain"`
}

AWS S3配置

func (Aws) UploadLoclFile

func (config Aws) UploadLoclFile(savePath, filePath string) (objectKey string, domain string, err error)

上传本地文件 @param savePath 保存至目录 @param filePath 本地文件路径 @return objectKey,domain,error

type Disk

type Disk struct {
	BucketPath string `mapstructure:"BucketPath"`
	Root       string `mapstructure:"Root"`
	Domain     string `mapstructure:"Domain"`
}

本地存储

func (*Disk) Client

func (aliyun *Disk) Client() *Disk

实例化客户端

func (*Disk) DownloadLocalFile

func (aliyun *Disk) DownloadLocalFile(objectKey, tempFile string) error

下载文件至指定位置 @param objectKey string 对象文件 @param tempFile 临时文件 @return error

func (*Disk) UploadLoclFile

func (aliyun *Disk) UploadLoclFile(savePath, filePath string) (objectKey string, domain string, err error)

上传本地文件 @param root string 保存至目录 @param filePath 本地文件路径 @return string,error

type HuaWei

type HuaWei struct {
	AccessKeyId     string `mapstructure:"AccessKeyId"`
	AccessKeySecret string `mapstructure:"AccessKeySecret"`
	EndPoint        string `mapstructure:"EndPoint"`
	BucketName      string `mapstructure:"BucketName"`
	StorageRoot     string `mapstructure:"StorageRoot"`
	StorageDomain   string `mapstructure:"StorageDomain"`
	ObsClient       *obs.ObsClient
	Error           error
}

华为云obs配置

func (*HuaWei) Client

func (huawei *HuaWei) Client() *HuaWei

实例化客户端

func (HuaWei) DownloadLocalFile

func (huawei HuaWei) DownloadLocalFile(objectKey, tempFile string) (err error)

下载文件至指定位置 @param objectKey string 对象文件 @param tempFile 临时文件 @return error

func (HuaWei) UploadLoclFile

func (huawei HuaWei) UploadLoclFile(savePath, filePath string) (objectKey string, domain string, err error)

上传本地文件 @param root string 保存至目录 @param filePath 本地文件路径 @return string,error

type Storage

type Storage interface {
	UploadLoclFile(savePath, filePath string) (objectKey string, domain string, err error)
	DownloadLocalFile(objectKey, tempFile string) (err error)
}

存储接口定义

Jump to

Keyboard shortcuts

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