效果:
代码:
export const getPhotoById = params => get(`${base}/weda/myLecture/poster/template/getPhotoById?id=${params.id}&isPreview=${params.isPreview}`,{}); // 获取原始的大图
后端
@Override
public void getPhotoById(PosterTemplate dto, HttpServletResponse response) throws Exception {
/省略
InputStream download = minioUtil.download("mpbucket", "sjs/wdjz/hbgl" + SLASH_SUFFIX + preview);
writeFile(response,download);
}
/**
* 将输入流输出到页面
*/
public static void writeFile(HttpServletResponse resp, InputStream inputStream) {
OutputStream out = null;
try {
out = resp.getOutputStream();
int len = 0;
byte[] b = new byte[1024];
while ((len = inputStream.read(b)) != -1) {
out.write(b, 0, len);
}
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}