需要将python检测的图片上传到java客户端,这里是一个简单的实现:
Java服务器:
@RequestMapping("/upload")
@ResponseBody
public String handleFileUpload(@RequestParam("image_file") MultipartFile file) {
if (!file.isEmpty()) {
try {
/*
这里仅是一个简单实现,请自定义更改
*/
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(new File(
file.getOriginalFilename())));
System.out.println(file.getName());
out.write(file.getBytes());
out.flush();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return "上传失败," + e.getMessage();
} catch (IOException e) {
e.printStackTrace();