bfs.go 884 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dao
  2. import (
  3. "context"
  4. "net/http"
  5. "go-common/library/database/bfs"
  6. "go-common/library/log"
  7. )
  8. // BfsData get bfs data
  9. func (d *Dao) BfsData(c context.Context, bfsURL string) (bs []byte, err error) {
  10. var (
  11. req *http.Request
  12. )
  13. if req, err = http.NewRequest(http.MethodGet, bfsURL, nil); err != nil {
  14. log.Error("NewRequest(bfsURL:%v),error(%v)", bfsURL, err)
  15. return
  16. }
  17. if bs, err = d.httpCli.Raw(c, req); err != nil {
  18. log.Error("Raw(bfsURL:%v),error(%v)", bfsURL, err)
  19. return
  20. }
  21. return
  22. }
  23. // BfsDmUpload .
  24. func (d *Dao) BfsDmUpload(c context.Context, fileName string, bs []byte) (location string, err error) {
  25. if location, err = d.bfsCli.Upload(c, &bfs.Request{
  26. Bucket: d.conf.Bfs.Dm,
  27. Filename: fileName,
  28. ContentType: "application/json",
  29. File: bs,
  30. }); err != nil {
  31. log.Error("bfs.BfsDmUpload error(%v)", err)
  32. return
  33. }
  34. return
  35. }