springboot 集成ftp

本文介绍了如何在SpringBoot项目中集成FTP服务,实现文件上传到阿里云。重点涉及了依赖配置、Controller代码、文件上传工具类的使用,以及在实现过程中需要注意的事项,包括阿里云防火墙设置、安全组21端口开放、FTP用户权限设定和Nginx的配置。同时推荐了FileZilla作为FTP客户端和SecurCRT作为SSH远程连接工具。
摘要由CSDN通过智能技术生成

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);

    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值