/**
* 算法结果下载
* @return
*/
@RequestMapping("/billingDownloadOutWrite")
public void billingDownloadOutWrite(@NotNull(message = "key不能为空") String ossKey,HttpServletRequest request,
HttpServletResponse response){
try{
LOG.info("开始获取key:{}",MessageConstant.Default.BASIC_DIRECTORY+ossKey);
InputStream inputStream = AliOSSUtils.getObject(MessageConstant.Default.BASIC_DIRECTORY+ossKey);
BufferedImage bi = ImageIO.read(inputStream);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String[] urlSplit = ossKey.split("[.]");
ImageIO.write(bi, urlSplit[1], baos); //经测试转换的图片是格式这里就什么格式,否则会失真
response.setHeader("Content-Type", "image/jpeg");
ImageIO.write(bi, urlSplit[1], response.getOutputStream());
}catch (Exception e){
e.printStackTrace();
}
}
网友评论