upload.go 956 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. xhttp "net/http"
  7. "net/url"
  8. "strconv"
  9. )
  10. //MergeUploadReq ..
  11. func (d *Dao) MergeUploadReq(c context.Context, rurl string, uploadID string, profile string, svid int64, auth string) (err error) {
  12. var (
  13. req *xhttp.Request
  14. )
  15. rurl = d.c.Upload.HTTPSchema + rurl
  16. param := make(url.Values)
  17. param.Set("uploadId", uploadID)
  18. param.Set("profile", profile)
  19. param.Set("biz_id", strconv.FormatInt(svid, 10))
  20. rurl = rurl + "?" + param.Encode()
  21. req, err = d.httpslowClient.NewRequest(xhttp.MethodPost, rurl, "", param)
  22. if err != nil {
  23. log.Errorw(c, "event", "MergeUploadReq d.httpClient.NewRequest err", "err", err)
  24. err = ecode.UploadFailed
  25. return
  26. }
  27. req.Header.Add("X-Upos-Auth", auth)
  28. if err = d.httpClient.Do(c, req, nil); err != nil {
  29. log.Errorw(c, "event", "MergeUploadReq d.httpClient.Do err", "err", err)
  30. err = ecode.UploadFailed
  31. return
  32. }
  33. return
  34. }