oss.go 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package oss
  2. import (
  3. "eta_gn/eta_obs/global"
  4. )
  5. const (
  6. STORAGESOURCE_OSS_NAME = "oss"
  7. STORAGESOURCE_MINIO_NAME = "minio"
  8. STORAGESOURCE_S3_NAME = "s3"
  9. )
  10. type OssClient interface {
  11. UploadFile(string, string, string) (string, error)
  12. GetUploadToken() (OssToken, error)
  13. }
  14. func NewOssClient() OssClient {
  15. switch global.CONFIG.Oss.ObjectStorageClient {
  16. case STORAGESOURCE_MINIO_NAME:
  17. return new(MinioOss)
  18. case STORAGESOURCE_S3_NAME:
  19. return new(S3Oss)
  20. default:
  21. // 默认使用阿里云OSS
  22. return new(AliOss)
  23. }
  24. }
  25. // OssToken 此处为了兼容前端那边所以有重复的
  26. type OssToken struct {
  27. AccessKeyId string
  28. SecretKeyId string
  29. RegionId string
  30. Bucketname string
  31. Endpoint string
  32. ImgHost string
  33. UseSSL string
  34. Port string
  35. //AccessKeyId string
  36. AccessKeySecret string
  37. SecurityToken string
  38. ExpiredTime string
  39. //RegionId string
  40. //Bucketname string
  41. //Endpoint string
  42. Imghost string
  43. S3ForceStyle bool
  44. S3Protocol string
  45. }