文件交互
上传文件到前端
1
2
3
4
5
6
7
8
9
10
11
12
@PostMapping("/packageExeParent")
public Result packageExeParent(HttpServletResponse response, @RequestBody JSONObject jsonObject) throws IOException {
// response.setHeader("content-type","application/octet-stream");
byte[] file = PackageExe.packageExe(jsonObject.getString("user_id"),"package\\ecloud_6.3.9.1_setup(20211021171044).exe");
try (OutputStream os = response.getOutputStream()){
os.write(file);
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
return Result.success();
}
获取response的 outputStream 将加工过的 exe文件直接转为 byte 字节数组 发送即可