init
continuous-integration/drone/push Build is passing Details

master v1.0.0
李光春 2 years ago
commit c9ce74c440

@ -0,0 +1,11 @@
kind: pipeline
type: docker
name: clone
steps:
- name: test-golang
image: golang:1.18
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go test -v ./...

8
.gitignore vendored

@ -0,0 +1,8 @@
.env
.git
.svn
.idea
.vscode
*.log
gomod.sh
/vendor/

@ -0,0 +1,25 @@
<h1>
<a href="https://www.dtapp.net/">Golang Storage</a>
</h1>
📦 Golang Storage
[comment]: <> (go)
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/gostorage?status.svg)](https://pkg.go.dev/go.dtapp.net/gostorage)
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/gostorage/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/gostorage)
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/gostorage )](https://goreportcard.com/report/go.dtapp.net/gostorage)
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net/gostorage)
#### 安装使用
```go
go get -v -u go.dtapp.net/gostorage
```
#### 导入
```go
import (
"go.dtapp.net/gostorage"
)
```

@ -0,0 +1,52 @@
package gostorage
import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"io"
)
// AliYun 阿里云 OSS 存储
type AliYun struct {
Endpoint string
AccessKeyId string
AccessKeySecret string
error error // 错误信息
client *oss.Client // 驱动
bucket *oss.Bucket // 存储空间
}
// NewAliYun 初始化
func NewAliYun(endpoint string, accessKeyId string, accessKeySecret string) *AliYun {
app := &AliYun{Endpoint: endpoint, AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret}
app.client, app.error = oss.New(endpoint, accessKeyId, accessKeySecret)
return app
}
// Bucket 存储空间
func (c *AliYun) Bucket(name string) *AliYun {
c.bucket, c.error = c.client.Bucket(name)
return c
}
// FileInfo 上传文件的信息
type FileInfo struct {
Path string // 文件路径
Name string // 文件名称
Url string // 文件地址
}
// PutObject 上传文件流
// @param file 文件流
// @param filePath 文件路径
// @param fileName 文件名称
func (c *AliYun) PutObject(file io.Reader, filePath, fileName string) (resp FileInfo, err error) {
objectKey := filePath
if fileName != "" {
objectKey = filePath + "/" + fileName
}
err = c.bucket.PutObject(objectKey, file)
resp.Path = filePath
resp.Name = fileName
resp.Url = objectKey
return
}

@ -0,0 +1 @@
package gostorage

@ -0,0 +1,12 @@
module go.dtapp.net/gostorage
go 1.18
require github.com/aliyun/aliyun-oss-go-sdk v2.2.3+incompatible
require (
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/satori/go.uuid v1.2.0 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

@ -0,0 +1,15 @@
github.com/aliyun/aliyun-oss-go-sdk v2.2.3+incompatible h1:KlwIELiuuvj7uMeEXrgXecPE3+xz/gGsDSnhL6Eztq0=
github.com/aliyun/aliyun-oss-go-sdk v2.2.3+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
golang.org/x/time v0.0.0-20220411224347-583f2d630306 h1:+gHMid33q6pen7kv9xvT+JRinntgeXO2AeZVd0AWD3w=
golang.org/x/time v0.0.0-20220411224347-583f2d630306/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

@ -0,0 +1 @@
package gostorage

@ -0,0 +1 @@
package gostorage

@ -0,0 +1 @@
package gostorage

@ -0,0 +1 @@
package gostorage

@ -0,0 +1 @@
package gostorage

@ -0,0 +1,3 @@
package gostorage
const Version = "1.0.0"

@ -0,0 +1,7 @@
package gostorage
import "testing"
func TestVersion(t *testing.T) {
t.Log(Version)
}
Loading…
Cancel
Save