springboot 集成ftp 上传文件到阿里云
依赖包:
<!-- 集成ftp-->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
controller:
RestController
@RequestMapping("/common")
public class CommonController {
@Autowired
FileUtil fileUtil;
@PostMapping("/upload")
public Result uploadFile(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException {
String url = fileUtil.upload2(file.getInputStream(), file.getOriginalFilename());
return Result.success(url);