| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.Base64; |
| | | |
| | | @RestController |
| | | @RequestMapping("face") |
| | | public class FaceController { |
| | |
| | | return jsonObject; |
| | | } |
| | | |
| | | @RequestMapping("/showFaceImg") |
| | | public void showFaceImg(String recordId, HttpServletResponse response){ |
| | | String oriStr = faceServer.queryOriStrById(recordId); |
| | | byte[] bytes = Base64.getDecoder().decode(oriStr); |
| | | OutputStream outputStream = null; |
| | | try { |
| | | outputStream = response.getOutputStream(); |
| | | outputStream.write(bytes); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } finally { |
| | | try { |
| | | if (outputStream!=null) { |
| | | outputStream.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |