| | |
| | | import ( |
| | | "encoding/base64" |
| | | "fmt" |
| | | "gat1400Exchange/util" |
| | | "math/rand" |
| | | "net/http" |
| | | "path" |
| | | "strconv" |
| | | "time" |
| | | |
| | |
| | | face := req.FaceListObject.FaceObject[0] |
| | | logger.Debug("Receive new face message, ip:%s, device id:%s faceId:%s, LeftTopX:%d, appearTime:%s", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX, face.FaceAppearTime) |
| | | |
| | | if config.ClientConf.UploadType == "url" { |
| | | for idx, img := range face.SubImageList.SubImageInfoObject { |
| | | if img.Type != "14" { |
| | | continue |
| | | } |
| | | |
| | | imageBytes, err := base64.StdEncoding.DecodeString(img.Data) |
| | | if err != nil { |
| | | logger.Warn("Decode Small Image Base64 String failure, %s", err.Error()) |
| | | c.AbortWithStatus(http.StatusBadRequest) |
| | | return |
| | | } |
| | | |
| | | today := time.Now().Format("2006-01-02") |
| | | imagePath := path.Join(config.LogConf.Path, "gat1400_face_images", today, img.ImageID+".jpeg") |
| | | err = util.WriteToFile(imagePath, imageBytes) |
| | | if err != nil { |
| | | face.SubImageList.SubImageInfoObject[idx].Data = "" |
| | | face.SubImageList.SubImageInfoObject[idx].StoragePath = config.ImageConf.ImageUriPrefix + "/" + today + "/" + img.ImageID + ".jpeg" |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 如果开启了下级, 身份应该是消息代理, 不再转发到服务器 |
| | | if config.ClientConf.Enable && config.ServeConf.Role == "agent" { |
| | | go a.Repository.VIIDFaceMsgForward(&req) |