simple_aws_tools

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

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

Go to latest
Published: Oct 9, 2019 License: MIT Imports: 9 Imported by: 0

README

simple-aws-tools

simple-aws 简单AWS 工具盒

Aws S3

Aws S3术语
  • Region: 存储数据所在的地理区域
  • Endpoint: 存储服务入口,Web服务入口点的URL
  • Bucket: 存储桶S3中用于存储对象的容器
  • Object: 对象是S3中存储的基本实体,由对象数据和原数据组成
  • Key: 键是存储桶中对象的唯一标识符,桶内的每个对象都只能有一个key
安装
go get github.com/dollarkillerx/simple-aws-tools
上传
	tools := simple_aws_tools.AwsTools{}
	tools.Init(simple_aws_tools.WithAccessKey("xxxxxx"),simple_aws_tools.WithRegion("xxxx"),simple_aws_tools.WithSecretKey("xxxxxxx"))

	upload := tools.InitUpload("pre-europe")

	// 遍历目录
	filelist := simple_aws_tools.GetFileList("test") // 返货目录下所有文件 的[]string
	for _,item := range filelist {
		file, e := os.Open(item)
		if e != nil {
			continue
		}
		defer file.Close()
		upload.UploadFile(file,item)
	}

Documentation

Overview

*

*

*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileList

func GetFileList(path string) []string

Types

type AwsTools

type AwsTools struct {
	Session *session.Session
}

func (*AwsTools) Init

func (a *AwsTools) Init(opts ...Option)

初始化 aws upload

func (*AwsTools) InitUpload

func (a *AwsTools) InitUpload(bucket string) *AwsUpload

初始化upload

type AwsUpload

type AwsUpload struct {
	// contains filtered or unexported fields
}

func (*AwsUpload) UploadFile

func (a *AwsUpload) UploadFile(file io.Reader, fileName string) error

文件上传 会自动创建文件夹

type Option

type Option func(opts *Options)

func WithAccessKey

func WithAccessKey(key string) Option

func WithEndPoint

func WithEndPoint(endPoint string) Option

func WithRegion

func WithRegion(reg string) Option

func WithSecretKey

func WithSecretKey(key string) Option

type Options

type Options struct {
	AccessKey string
	SecretKey string
	EndPoint  string
	Region    string
}

Jump to

Keyboard shortcuts

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