liuxiaolong
2019-08-21 ea5df990ee13cf2ca03b0ee757f2f67c789cb93c
controllers/fileController.go
@@ -548,7 +548,6 @@
func uploadFileReturnAddr(file multipart.File, filename string, tableId string) (string, map[string]interface{}, error) {
   defer file.Close()
   field := ""
   // weedfs 上传
   fileBytes, err := ioutil.ReadAll(file)
   if err !=nil {
@@ -580,29 +579,22 @@
   cutFaceImgData := util.SubImg(*pI, int(rcFace.Left), int(rcFace.Top), int(rcFace.Right), int(rcFace.Bottom))
   logger.Debug("SubImg用时:", time.Since(t1))
   t1 = time.Now()
   fileInfo, e := esutil.PostFormData(weedfsUri, filename, "file", cutFaceImgData)
   weedFilePath, e := WeedFSClient.UploadFile(weedfsUri, filename, cutFaceImgData)
   logger.Debug("上传到weedfs用时:", time.Since(t1))
   t1 = time.Now()
   if e != nil {
      fmt.Println(e.Error())
      return "", nil, e
   } else {
      field = fileInfo[picUrlField].(string) // 文件路径
   }
   if strings.Contains(field,"/"){
      idx := strings.Index(field, "/")
      field = field[idx+1:]
   }
   ext := path.Ext(filename)
   fileNameOnly := strings.TrimSuffix(filename, ext)
   dbperson := new(models.Dbtablepersons)
   dbperson.PersonPicUrl = field //  图片路经
   dbperson.PersonPicUrl = weedFilePath //  图片路经
   dbperson.TableId = tableId           //
   dbperson.PersonName = fileNameOnly       // 图片名
   dbperson.Enable = 1 //默认有效
   // 演示base64编码
   dbperson.FaceFeature = faceBase64 // 特征值base64 码
   result := addDbPerson(dbperson)