Skip to content

lily-lee/oss-uni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ossuni

阿里云与腾讯云存储的统一接口,

为了方便在两个云之间做切换

Install & Update

# Install
go get github.com/lily-lee/oss-uni/ossuni

# Update
go get -u github.com/lily-lee/oss-uni/ossuni

Usage

package main

import (
    "github.com/lily-lee/oss-uni/ossuni"
    "log"
)

// example
func main() {
	ossType := ossuni.OssType(ossuni.ALIYUN)
	client := ossuni.NewClient(ossType)
	client.Init(ossuni.Config{
		OssType:     ossType,
		Scheme:      "https",
		AppID:       "QCloud APPID",
		SecretID:    "QCloud SecretID",
		SecretKey:   "QCloud SecretKey",
		AuthExpired: 600,

		Endpoint:        "Aliyun OSS endpoint",
		AccessKeyID:     "Aliyun OSS AccessKeyID",
		AccessKeySecret: "Aliyun OSS AccessKeySecret",
	})
	param := ossuni.ObjectParam{
		Bucket: "Your Bucket Name",
		Key:    "readme",
		Region: "Your Bucket Region", // only for qcloud cos
	}
	e := client.PutObjectFromFile(param, "../README.md")
	log.Println(e)
}

LICENSE

MIT License

Releases

No releases published

Packages

No packages published

Languages