dos3

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 11 Imported by: 0

README

Dos3 搞定文件上传

如何使用
在项目开始调用初始化
if err := Init("http://127.0.0.1:9000", "default", "minioadmin", "minioadmin"); err != nil {
}
使用函数操作文件

func UploadFile(bucket string, fp *os.File) (key string, err error) {
return GlobalS3.PutObj(bucket, fp)
}

func ListFile(bucket string) ([]*s3.Object, error) {
return GlobalS3.ListObj(bucket)
}

func DeleteFile(bucket, key string) error {
return GlobalS3.DelObj(bucket, key)
}

func DownloadFile(bucket, key string) (io.ReadCloser, error) {
return GlobalS3.DownObj(bucket, key)
}
使用GlobalS3自定义函数

var (
//全局S3对象
GlobalS3 *S3
//请求超时时间
Timeout  = 30 * time.Minute
)

type S3 struct {
EndPoint  string
Region    string
AccessKey string
SecretKey string
Sess      *session.Session
}
测试示例
参阅测试示例
遇到问题
请提交issue

Documentation

Overview

基于aws s3 sdk实现对minio对象存储的上传、下载、列出、删除操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(bucket, key string) error

func DownloadFile

func DownloadFile(bucket, key string) (io.ReadCloser, error)

func Init

func Init(endPoint, region, accessKey, secretKey string) error

func ListFile

func ListFile(bucket string) ([]*s3.Object, error)

func UploadFile

func UploadFile(bucket string, fp *os.File) (key string, err error)

Types

type S3

type S3 struct {
	EndPoint  string
	Region    string
	AccessKey string
	SecretKey string
	Sess      *session.Session
}
var (
	//全局S3对象
	GlobalS3 *S3
	//请求超时时间
	Timeout = 30 * time.Minute
)

func (*S3) DelObj

func (s *S3) DelObj(bucket, key string) error

删除对象

func (*S3) DownObj

func (s *S3) DownObj(bucket, key string) (io.ReadCloser, error)

下载对象

func (*S3) ListObj

func (s *S3) ListObj(bucket string) ([]*s3.Object, error)

列出所有对象

func (*S3) PutObj

func (s *S3) PutObj(bucket string, fp *os.File) (key string, err error)

上传对象

Jump to

Keyboard shortcuts

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