[英]Upload image to another server
I am working on a Spring Boot application.我正在开发 Spring 引导应用程序。 I have image upload functionalities in the application.
我在应用程序中有图像上传功能。 Until now it was needed to save the image in the same server.
到目前为止,需要将图像保存在同一服务器中。 So I did it like below:
所以我这样做如下:
@PostMapping("/upload")
public String upload(@RequestParam("photo") MultipartFile photo) throws IOException {
Path currentPath = Paths.get("");
Path absolutePath = currentPath.toAbsolutePath();
Path photoPath = Paths.get(absolutePath + "/photos/photo.png");
byte[] photoBytes = photo.getBytes();
Files.write(photoPath, photoBytes);
return "redirect:/index";
}
Now it is needed to save the image in photos folder of another server with ip address like: 192.168.148.154现在需要将图像保存在另一台服务器的照片文件夹中,地址为 ip,例如:192.168.148.154
How can I save image to another server?如何将图像保存到另一台服务器?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.