upload.go 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package upload
  2. import (
  3. "mime/multipart"
  4. "github.com/flipped-aurora/gin-vue-admin/server/global"
  5. )
  6. //@author: [ccfish86](https://github.com/ccfish86)
  7. //@author: [SliverHorn](https://github.com/SliverHorn)
  8. //@interface_name: OSS
  9. //@description: OSS接口
  10. type OSS interface {
  11. UploadFile(file *multipart.FileHeader) (string, string, error)
  12. DeleteFile(key string) error
  13. }
  14. //@author: [ccfish86](https://github.com/ccfish86)
  15. //@author: [SliverHorn](https://github.com/SliverHorn)
  16. //@function: NewOss
  17. //@description: OSS接口
  18. //@description: OSS的实例化方法
  19. //@return: OSS
  20. func NewOss() OSS {
  21. switch global.GVA_CONFIG.System.OssType {
  22. case "local":
  23. return &Local{}
  24. case "qiniu":
  25. return &Qiniu{}
  26. case "tencent-cos":
  27. return &TencentCOS{}
  28. case "aliyun-oss":
  29. return &AliyunOSS{}
  30. default:
  31. return &Local{}
  32. }
  33. }