| | |
| | | |
| | | //文件全路径 |
| | | String fileName = fileDirName + File.separator + uName + ".jpg"; |
| | | |
| | | FileOutputStream fot=null; |
| | | try { |
| | | FileOutputStream fot = new FileOutputStream(fileName); |
| | | |
| | | fot = new FileOutputStream(fileName); |
| | | fot.write(dataBytes); |
| | | fot.flush(); |
| | | fot.close(); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | if(fot!=null){ |
| | | try { |
| | | fot.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*=========数据库表更新===========*/ |
| | |
| | | * 人脸库管理: 更新 |
| | | * @return |
| | | */ |
| | | @PutMapping |
| | | @PostMapping("update") |
| | | @ApiOperation(value = "更新") |
| | | public Response update(@RequestBody String fileData,@RequestParam String uName){ |
| | | //传参,uName,fileData--文件流 |
| | | |
| | | //过滤 uName的特殊字符,避免路径遍历攻击 |
| | | uName = ActionUtil.filterFileName(uName); |
| | | //由于图片字符串是由base64编码的,解码成字节数组 |
| | | fileData = fileData.replaceAll(" ", "+"); |
| | | fileData = fileData.split(",")[1]; |
| | |
| | | |
| | | //文件全路径 |
| | | String fileName = fileDirName + File.separator + uName + ".jpg"; |
| | | |
| | | FileOutputStream fot =null; |
| | | try { |
| | | FileOutputStream fot = new FileOutputStream(fileName); |
| | | |
| | | fot = new FileOutputStream(fileName); |
| | | fot.write(dataBytes); |
| | | fot.flush(); |
| | | fot.close(); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | if(fot!=null){ |
| | | try { |
| | | fot.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return new Response().setII(1,"更新成功"); |
| | | } |
| | |
| | | * 人脸库管理: 删除 |
| | | * @return |
| | | */ |
| | | @DeleteMapping |
| | | @PostMapping("delete") |
| | | @ApiOperation(value = "删除") |
| | | @Transactional |
| | | public Response delete(@RequestParam Integer uId,@RequestParam Integer faceId, |
| | | @RequestParam String uName,HttpServletRequest request){ |
| | | |
| | | //过滤 uName的特殊字符,避免路径遍历攻击 |
| | | uName = ActionUtil.filterFileName(uName); |
| | | //更新user_inf和face表 |
| | | service.update(uId,faceId); |
| | | |