go-common/app/interface/bbq/app-bbq/dao/image.go

26 lines
575 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package dao
import (
"context"
image "go-common/app/service/bbq/video-image/api/grpc/v1"
"go-common/library/log"
)
//Upload .
func (d *Dao) Upload(c context.Context, fileName string, filePath string, file []byte) (location string, err error) {
imageReq := &image.ImgUploadRequest{
Filename: fileName,
Dir: filePath,
File: file,
}
imageRes, err := d.imageClient.ImgUpload(c, imageReq)
if err != nil {
log.Errorv(c, log.KV("event", "grpc/imageupload"), log.KV("err", err))
return
}
if imageRes != nil {
location = imageRes.Location
}
return
}