1.后端在Controller中获取到HttpServletResponse response
2.获取到文件inputStream,比如从oss下载到
3.流写入response

// 设置响应格式
response.reset();
response.setContentType("application/octet-stream");
response.addHeader("content-disposition", "attachment; filename=" + fileName);

BufferedInputStream bis = null;
BufferedOutputStream bos = null;
bis = new BufferedInputStream(inputStream);
bos = new BufferedOutputStream(response.getOutputStream());

byte[] bytes = new byte[2048];
int len;

while ((len = bis.read(bytes, 0, bytes.length)) != -1) {
    bos.write(bytes, 0, len);
}