| | |
| | | public class AlarmController { |
| | | private IVideoAlarmReportService videoAlarmReportService; |
| | | |
| | | private static Integer index = 0; |
| | | |
| | | @Autowired |
| | | private VideoUtil videoUtil; |
| | | |
| | |
| | | // @GetMapping(value = "/img") |
| | | @ResponseBody |
| | | public byte[] getImages(HttpServletResponse response, @RequestParam String fileUrl, @RequestParam String OSSAccessKeyId, @RequestParam String Signature) { |
| | | try { |
| | | |
| | | index = 0; |
| | | return getBytes(fileUrl, OSSAccessKeyId, Signature); |
| | | |
| | | } |
| | | |
| | | private byte[] getBytes(String fileUrl, String OSSAccessKeyId, String Signature) { |
| | | try { |
| | | if (index < 10) { |
| | | index++; |
| | | System.out.println("getImages获取图片地址:" + fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId + "&Signature=" + Signature); |
| | | URL url = new URL(fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId + "&Signature=" + Signature); |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | |
| | | |
| | | InputStream inputStream = conn.getInputStream();// 通过输入流获取图片数据 |
| | | |
| | | |
| | | byte[] data = readInputStream(inputStream); |
| | | System.out.println("getImages获取图片成功"); |
| | | |
| | | |
| | | System.out.println("getImages -图片64"); |
| | | System.out.println(Base64.getEncoder().encodeToString(data)); |
| | | return data; |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("getImages获取图片失败:" + e.getMessage()); |
| | | System.out.println(index + "getImages获取图片失败:" + e.getMessage()); |
| | | getBytes(fileUrl, OSSAccessKeyId, Signature); |
| | | // e.printStackTrace(); |
| | | } |
| | | return null; |