/** * 腾讯云活体检测 */ @NoAuth @ApiOperation(value = "腾讯云活体检测",httpMethod = "POST") @RequestMapping(value = "/getLiveness", method = RequestMethod.POST) public JSONResult getLiveness(MultipartFile file) { try { //String path = SaveFileFromInputStream(file.getInputStream(), "D:/YL/mp4", System.currentTimeMillis() + file.getOriginalFilename()); String path = SaveFileFromInputStream(file.getInputStream(), "/root/mp4", System.currentTimeMillis() + file.getOriginalFilename()); return wechatInfoFacade.getLiveness(path); } catch (Exception e) { e.printStackTrace(); return JSONResult.ERR(e.getMessage()); } } public String SaveFileFromInputStream(InputStream stream, String path, String filename) throws IOException { FileOutputStream fs=new FileOutputStream( path + "/"+ filename); byte[] buffer =new byte[1024*1024]; int bytesum = 0; int byteread = 0; while ((byteread=stream.read(buffer))!=-1) { bytesum+=byteread; fs.write(buffer,0,byteread); fs.flush(); } fs.close(); stream.close(); return path + "/"+ filename; }
上传文件
最新推荐文章于 2021-06-30 16:49:33 发布