mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Initial commit
This commit is contained in:
52
server/storage/s3.go
Normal file
52
server/storage/s3.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type S3Storage struct {
|
||||
EndPoint string
|
||||
AccessKeyID string
|
||||
SecretAccessKey string
|
||||
BucketName string
|
||||
}
|
||||
|
||||
func (s *S3Storage) Upload(filePath string) (string, error) {
|
||||
// TODO: Implement S3 upload logic here
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (s *S3Storage) Download(storageKey string) (string, error) {
|
||||
// TODO: Implement S3 download logic here
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (s *S3Storage) Delete(storageKey string) error {
|
||||
// TODO: Implement S3 delete logic here
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *S3Storage) ToString() string {
|
||||
data, _ := json.Marshal(s)
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func (s *S3Storage) FromString(config string) error {
|
||||
var s3Config S3Storage
|
||||
if err := json.Unmarshal([]byte(config), &s3Config); err != nil {
|
||||
return err
|
||||
}
|
||||
s.EndPoint = s3Config.EndPoint
|
||||
s.AccessKeyID = s3Config.AccessKeyID
|
||||
s.SecretAccessKey = s3Config.SecretAccessKey
|
||||
s.BucketName = s3Config.BucketName
|
||||
if s.EndPoint == "" || s.AccessKeyID == "" || s.SecretAccessKey == "" || s.BucketName == "" {
|
||||
return errors.New("invalid S3 configuration")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *S3Storage) Type() string {
|
||||
return "s3"
|
||||
}
|
Reference in New Issue
Block a user