后端代码:
response.setCharacterEncoding("utf-8");
response.setContentType("image/*");
response.setHeader("Content-Disposition", "inline;fileName=deliveryBill");
InputStream in = ossObject.getObjectContent();
OutputStream out = response.getOutputStream();
byte[] b = new byte[1024];
while ((in.read(b))!=-1) {
out.write(b);
}
out.flush();
in.close();
out.close();
显示出来就这样:
颜色已经完全失真,且显示不完整。
前端是直接用的 img src="url" 获取后端的二进制流。