initialize.go 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package file_store
  2. import "fmt"
  3. type OXS struct {
  4. // Endpoint 访问域名
  5. Endpoint string
  6. // AccessKeyID AK
  7. AccessKeyID string
  8. // AccessKeySecret AKS
  9. AccessKeySecret string
  10. // BucketName 桶名称
  11. BucketName string
  12. }
  13. // Setup 配置文件存储driver
  14. func (e *OXS) Setup(driver DriverType, options ...ClientOption) FileStoreType {
  15. fileStoreType := driver
  16. var fileStore FileStoreType
  17. switch fileStoreType {
  18. case AliYunOSS:
  19. fileStore = new(ALiYunOSS)
  20. err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName)
  21. if err != nil {
  22. fmt.Println(err)
  23. }
  24. return fileStore
  25. case HuaweiOBS:
  26. fileStore = new(HuaWeiOBS)
  27. err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName)
  28. if err != nil {
  29. fmt.Println(err)
  30. }
  31. return fileStore
  32. case QiNiuKodo:
  33. fileStore = new(QiNiuKODO)
  34. err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName)
  35. if err != nil {
  36. fmt.Println(err)
  37. }
  38. return fileStore
  39. }
  40. return nil
  41. }