image.go 575 B

12345678910111213141516171819202122232425
  1. package dao
  2. import (
  3. "context"
  4. image "go-common/app/service/bbq/video-image/api/grpc/v1"
  5. "go-common/library/log"
  6. )
  7. //Upload .
  8. func (d *Dao) Upload(c context.Context, fileName string, filePath string, file []byte) (location string, err error) {
  9. imageReq := &image.ImgUploadRequest{
  10. Filename: fileName,
  11. Dir: filePath,
  12. File: file,
  13. }
  14. imageRes, err := d.imageClient.ImgUpload(c, imageReq)
  15. if err != nil {
  16. log.Errorv(c, log.KV("event", "grpc/imageupload"), log.KV("err", err))
  17. return
  18. }
  19. if imageRes != nil {
  20. location = imageRes.Location
  21. }
  22. return
  23. }