From aa91d7884e7fef55b47d6a4905596f72a5ef1ac3 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期六, 30 五月 2020 17:43:03 +0800 Subject: [PATCH] fix sdkType unTar --- controllers/fileController.go | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/controllers/fileController.go b/controllers/fileController.go index e2495b9..d6370fa 100644 --- a/controllers/fileController.go +++ b/controllers/fileController.go @@ -71,7 +71,7 @@ filename := header.Filename var result = make(map[string]string) if picType == "1" { - fileNameOnly, _, err, faceFeature := uploadFileReturnAddr(file, filename, "", false) + _, _, err, faceFeature, faceUrlPath := uploadFileReturnAddr(file, filename, "", false) if err != nil { if err.Error() == "NotFeatureFindError" { util.ResponseFormat(c, code.NotFeatureFindError, filename) @@ -80,7 +80,7 @@ } return } - result["picUrl"] = fileNameOnly + result["picUrl"] = faceUrlPath result["faceFeature"] = faceFeature } else { localConf, err2 := cache.GetServerInfo() @@ -492,6 +492,9 @@ return } faceB = decodeF + } else { + util.ResponseFormat(c, code.ComError, "鏈潯浜鸿劯鎶撴媿鐗瑰緛涓虹┖锛岃妫�鏌�") + return } } @@ -779,24 +782,24 @@ log.Fatalln(err) }*/ -func uploadFileReturnAddr(file multipart.File, filename string, tableId string, add2Db bool) (string, map[string]interface{}, error, string) { +func uploadFileReturnAddr(file multipart.File, filename string, tableId string, add2Db bool) (string, map[string]interface{}, error, string, string) { defer file.Close() // weedfs 涓婁紶 fileBytes, err := ioutil.ReadAll(file) if err !=nil { - return "",nil,err,"" + return "",nil,err,"","" } //灏嗕笂浼犵殑鍥剧墖浜や汉鑴告娴嬪拰浜鸿劯鎻愬彇锛岃幏寰楃壒寰� var faceBase64="" faceArr, err, pI := service.GetFaceFeaFromSdk(fileBytes, time.Second*5) if faceArr ==nil { - return "",nil,errors.New("NotFeatureFindError"),"" + return "",nil,errors.New("NotFeatureFindError"),"","" } var rcFace *protomsg.Rect if err ==nil && len(faceArr) >0 { if len(faceArr) >1 { - return "",nil, errors.New("TooManyFaces"),"" + return "",nil, errors.New("TooManyFaces"),"","" } for _,r := range faceArr { //鎷垮埌浜鸿劯鐨勫潗鏍� @@ -809,7 +812,7 @@ localConf, err2 := cache.GetServerInfo() if err2 !=nil || localConf.WebPicIp == "" { logger.Debug("localConfig is wrong!!!") - return "",nil,err2,"" + return "",nil,err2,"","" } var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" //鏍规嵁浜鸿劯鍧愭爣鎵e嚭浜鸿劯灏忓浘 @@ -822,7 +825,7 @@ t1 = time.Now() if e != nil { logger.Debug("WeedFSClient.UploadFile err:", e) - return "", nil, e,"" + return "", nil, e,"","" } ext := path.Ext(filename) @@ -840,8 +843,8 @@ result = addDbPerson(dbperson) } - logger.Debug("addDbPerson鐢ㄦ椂锛�", time.Since(t1)) - return fileNameOnly, result, nil,faceBase64 + logger.Debug("addDbPerson鐢ㄦ椂锛�", time.Since(t1), "result:", result) + return fileNameOnly, result, nil,faceBase64, weedFilePath } @@ -898,7 +901,7 @@ lock.Unlock() return } - field, _, err1,_ := uploadFileReturnAddr(file, filename, tableId, true) + field, _, err1,_,_ := uploadFileReturnAddr(file, filename, tableId, true) lock.Lock() if err1 != nil || field == "" { if err1 !=nil && err1.Error() == "NotFeatureFindError" { -- Gitblit v1.8.0