You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

client.go 706 B

123456789101112131415161718192021222324252627
  1. package obs
  2. import (
  3. "github.com/aws/aws-sdk-go-v2/aws"
  4. "github.com/aws/aws-sdk-go-v2/credentials"
  5. "github.com/aws/aws-sdk-go-v2/service/s3"
  6. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  7. )
  8. func CreateS2Client(addr *cdssdk.OBSType) (*s3.Client, string, error) {
  9. awsConfig := aws.Config{}
  10. cre := aws.Credentials{
  11. AccessKeyID: addr.AK,
  12. SecretAccessKey: addr.SK,
  13. }
  14. awsConfig.Credentials = &credentials.StaticCredentialsProvider{Value: cre}
  15. awsConfig.Region = addr.Region
  16. options := []func(*s3.Options){}
  17. options = append(options, func(s3Opt *s3.Options) {
  18. s3Opt.BaseEndpoint = &addr.Endpoint
  19. })
  20. cli := s3.NewFromConfig(awsConfig, options...)
  21. return cli, addr.Bucket, nil
  22. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。