| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | |
| | |
| | | @RestController |
| | | @RequestMapping("/API") |
| | | public class AlarmController { |
| | | |
| | | |
| | | private IVideoAlarmReportService videoAlarmReportService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "获取图片") |
| | | @GetMapping(value = "/img", produces = MediaType.IMAGE_PNG_VALUE) |
| | | @GetMapping(value = "/img", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE}) |
| | | // @GetMapping(value = "/img") |
| | | @ResponseBody |
| | | public byte[] getImages(HttpServletResponse response, @RequestParam String fileUrl) { |
| | | public byte[] getImages(HttpServletResponse response, @RequestParam String fileUrl, @RequestParam String OSSAccessKeyId, @RequestParam String Signature) { |
| | | try { |
| | | URL url = new URL(fileUrl); |
| | | URL url = new URL(fileUrl + "&OSSAccessKeyId=" + OSSAccessKeyId +"&Signature=" + Signature); |
| | | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
| | | conn.setRequestMethod("GET"); |
| | | conn.setConnectTimeout(5 * 1000); |
| | | conn.setConnectTimeout(10 * 1000); |
| | | conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); |
| | | |
| | | InputStream inputStream = conn.getInputStream();// 通过输入流获取图片数据 |