Skip to content

Commit

Permalink
增加对腾讯云COS vistual-hosted-style的支持
Browse files Browse the repository at this point in the history
- 增加支持腾讯云COS的vistual hosted style支持,minio-go官方暂不支持,临时fork了仓库修复并提交PR给官方
- 增加ListBucket方法
  • Loading branch information
jorben committed Mar 16, 2024
1 parent 8b0387b commit 2eff25e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/jorben/rsync-object-storage

go 1.20

replace github.com/minio/minio-go/v7 => github.com/jorben/minio-go/v7 v7.0.0-20240315175604-7872ece73c72

require (
github.com/fsnotify/fsnotify v1.7.0
github.com/ldigit/config v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jorben/minio-go/v7 v7.0.0-20240315175604-7872ece73c72 h1:nepIqgARuvEH5LH8CHM+QqQ4U/I2wnlQcOYMDVUFaAE=
github.com/jorben/minio-go/v7 v7.0.0-20240315175604-7872ece73c72/go.mod h1:XAvOPJQ5Xlzk5o3o/ArO2NMbhSGkimC+bpW/ngRKDmQ=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
Expand All @@ -21,8 +23,6 @@ github.com/ldigit/config v1.0.0 h1:8wJhZiwci/wleOMeWKSBWpcahoJ5rhxVDemFR7Tp2eQ=
github.com/ldigit/config v1.0.0/go.mod h1:MoR2Eo10xNcLE4hT2CL9sQRmsGANJUXAcpHCGtbekdg=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.69 h1:l8AnsQFyY1xiwa/DaQskY4NXSLA2yrGsW5iD9nRPVS0=
github.com/minio/minio-go/v7 v7.0.69/go.mod h1:XAvOPJQ5Xlzk5o3o/ArO2NMbhSGkimC+bpW/ngRKDmQ=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func main() {
if err != nil {
log.Fatalf("NewStorage err: %s", err.Error())
}

if err = s.BucketExists(ctx); err != nil {
log.Fatalf("BucketExist err: %s", err.Error())
}
Expand Down
13 changes: 13 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ func NewStorage(c *config.SyncConfig) (*Storage, error) {
}, nil
}

// ListBucket 列出Bucket列表
func (s *Storage) ListBucket(ctx context.Context) ([]string, error) {
var bucketList []string
bucketInfoList, err := s.Minio.ListBuckets(ctx)
if err != nil {
return bucketList, err
}
for _, bucket := range bucketInfoList {
bucketList = append(bucketList, bucket.Name)
}
return bucketList, nil
}

// BucketExists 判断Bucket是否存在
func (s *Storage) BucketExists(ctx context.Context) error {
exist, err := s.Minio.BucketExists(ctx, s.Bucket)
Expand Down

0 comments on commit 2eff25e

Please sign in to comment.