-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0fdcf0
commit b235e69
Showing
11 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ reaper run | |
REAPER支持多种存储类型。 | ||
|
||
- [x] 文件 | ||
- [ ] AWS S3 | ||
- [x] AWS S3 | ||
|
||
## 使用 Docker 运行 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package storage | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"github.com/leslieleung/reaper/internal/ui" | ||
"github.com/minio/minio-go/v7" | ||
"github.com/minio/minio-go/v7/pkg/credentials" | ||
) | ||
|
||
var _ Storage = (*S3)(nil) | ||
|
||
type S3 struct { | ||
Endpoint string | ||
Bucket string | ||
Region string | ||
AccessKeyID string | ||
SecretAccessKey string | ||
|
||
client *minio.Client | ||
} | ||
|
||
func New(endpoint, bucket, region, accessKeyID, secretAccessKey string) (*S3, error) { | ||
s3 := &S3{ | ||
Endpoint: endpoint, | ||
Bucket: bucket, | ||
Region: region, | ||
AccessKeyID: accessKeyID, | ||
SecretAccessKey: secretAccessKey, | ||
} | ||
|
||
client, err := minio.New(s3.Endpoint, &minio.Options{ | ||
Creds: credentials.NewStaticV4(s3.AccessKeyID, s3.SecretAccessKey, ""), | ||
Secure: true, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
s3.client = client | ||
return s3, nil | ||
} | ||
|
||
func (s S3) ListObject(prefix string) ([]Object, error) { | ||
// TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (s S3) GetObject(identifier string) (Object, error) { | ||
// TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (s S3) PutObject(identifier string, data []byte) error { | ||
size := int64(len(data)) | ||
info, err := s.client.PutObject(context.Background(), s.Bucket, identifier, bytes.NewReader(data), size, minio.PutObjectOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
ui.Printf("info: %v", info) | ||
return nil | ||
} | ||
|
||
func (s S3) DeleteObject(identifier string) error { | ||
// TODO implement me | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters