springboot开发环境下搭建ftp+nginx图片服务器以及其他文件的存储

【ZZULIOJ】郑州轻工业大学oj题解整合 写在前面 关于ZZULIOJ题解 学习编程,想要巩固无非就是刷题或者做项目,然后因为我大一开始是刷郑轻的题目,就想着自己整合一下自己写的题目。既是复习也是笔记吧。 题解(内有题目描述) 1000 整数a+b 1001 植树问题 1002 简单多项式求值 1003 两个整数的四则运算 1004 三位数的数位分离 1005 整数幂 1006 求等差数列的和 1007 鸡兔同笼 1008 美元和人民币 1009 求平均分 1010 求圆的周长和面积 1011 圆柱体表面积 1012 求绝对值 1013 求两点间 阅读详情

一、在搭建一个ftp服务器用于存储文件

二、下载nginx,安装完成后更改配置文件

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
		
		location ~ \.(gif|jpg|jpeg|png|bmp|swf)$ {   //设置图片的格式
            root   D:/cateringFTP;     //ftp跟目录
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

三、上传文件到ftp

依赖

<!--ftp文件上传-->
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.3</version>
        </dependency>

FtpUtil如下

/**
 * 
 */
package shqn.sthj.modules.catering.utils;

import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
/**
 * @author hxl
 * @date 2019年10月31日
 * FtpUtil.java
 */
@Component
public class FtpUtil {

    Logger logger = Logger.getLogger(getClass());
    private String LOCAL_CHARSET = "GBK";

    //ftp服务器地址
    String hostname = "192.168.2.119";
    
    //ftp服务器端口
    int port = 22;

    //ftp登录账号
    String username = "catering";

    //ftp登录密码
    String password = "catering";

    //ftp保存目录
    String basePath = "";

    /**
     * 初始化ftp服务器
     */
    public FTPClient getFtpClient() {
        FTPClient ftpClient = new FTPClient();
        ftpClient.setControlEncoding("utf-8");

        try {
            ftpClient.setDataTimeout(1000 * 120);//设置连接超时时间
            logger.info("connecting...ftp服务器:" + hostname + ":" + port);
            ftpClient.connect(hostname,port); // 连接ftp服务器
            ftpClient.login(username, password); // 登录ftp服务器
            int replyCode = ftpClient.getReplyCode(); // 是否成功登录服务器
            if (FTPReply.isPositiveCompletion(ftpClient.sendCommand(
                    "OPTS UTF8", "ON"))) {      // 开启服务器对UTF-8的支持,如果服务器支持就用UTF-8编码,否则就使用本地编码(GBK).
                LOCAL_CHARSET = "UTF-8";
            }
            if (!FTPReply.isPositiveCompletion(replyCode)) {
                logger.error("connect failed...ftp服务器:" + hostname + ":" + port);
            }
            logger.info("connect successfu...ftp服务器:" + hostname + ":" + port);
        } catch (MalformedURLException e) {
            logger.error(e.getMessage(), e);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
        return ftpClient;
    }


    /**
     * 上传文件
     *
     * @param targetDir    ftp服务保存地址
     * @param fileName    上传到ftp的文件名
     * @param inputStream 输入文件流
     * @return
     */
    public boolean uploadFileToFtp(String targetDir, String fileName, InputStream inputStream) {
        boolean isSuccess = false;
        String servicePath = String.format("%s%s%s", basePath, "/", targetDir);
        FTPClient ftpClient = getFtpClient();
//      makeDirectory(ftpClient,servicePath); //创建文件夹
        
        
        
     // 切换到根目录
        try {
			ftpClient.changeWorkingDirectory("/");
			String path = servicePath;
	        String[] pah = path.split("/");         
	        // 分层创建目录
	        for (String pa : pah) {
	            System.out.println(pa);
	            ftpClient.makeDirectory(pa);
	            // 切到到对应目录
	            ftpClient.changeWorkingDirectory(pa);
	        } 
		} catch (IOException e1) {
			e1.printStackTrace();
		}
        
        
        try {
            if (ftpClient.isConnected()) {
                logger.info("开始上传文件到FTP,文件名称:" + fileName);
                ftpClient.setFileType(FTP.BINARY_FILE_TYPE);//设置上传文件类型为二进制,否则将无法打开文件
                ftpClient.makeDirectory(servicePath);
                ftpClient.changeWorkingDirectory(servicePath);
                //设置为被动模式(如上传文件夹成功,不能上传文件,注释这行,否则报错refused:connect  )
                ftpClient.enterLocalPassiveMode();//设置被动模式,文件传输端口设置
                ftpClient.storeFile(fileName, inputStream);
                inputStream.close();
                ftpClient.logout();
                isSuccess = true;
                logger.info(fileName + "文件上传到FTP成功");
            } else {
                logger.error("FTP连接建立失败");
            }
        } catch (Exception e) {
            logger.error(fileName + "文件上传到FTP出现异常");
            logger.error(e.getMessage(), e);
        } finally {
            closeFtpClient(ftpClient);
            closeStream(inputStream);
        }
        return isSuccess;
    }

    public void closeStream(Closeable closeable) {
        if (null != closeable) {
            try {
                closeable.close();
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    //改变目录路径
    public boolean changeWorkingDirectory(FTPClient ftpClient, String directory) {
        boolean flag = true;
        try {
            flag = ftpClient.changeWorkingDirectory(directory);
            if (flag) {
                logger.info("进入文件夹" + directory + " 成功!");

            } else {
                logger.info("进入文件夹" + directory + " 失败!开始创建文件夹");
            }
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
        return flag;
    }

    //创建多层目录文件,如果有ftp服务器已存在该文件,则不创建,如果无,则创建
    public boolean CreateDirecroty(FTPClient ftpClient, String remote) throws IOException {
        boolean success = true;

        String directory = remote;
        if (!remote.endsWith(File.separator)) {
            directory = directory + File.separator;
        }
        // 如果远程目录不存在,则递归创建远程服务器目录
        if (!directory.equalsIgnoreCase(File.separator) && !changeWorkingDirectory(ftpClient, new String(directory))) {
            int start = 0;
            int end = 0;
            if (directory.startsWith(File.separator)) {
                start = 1;
            } else {
                start = 0;
            }
            end = directory.indexOf(File.separator, start);
            String path = "";
            String paths = "";
            while (true) {
                String subDirectory = new String(remote.substring(start, end).getBytes("GBK"), "iso-8859-1");
                path = path + File.separator + subDirectory;
                if (!existFile(ftpClient, path)) {
                    if (makeDirectory(ftpClient, subDirectory)) {
                        changeWorkingDirectory(ftpClient, subDirectory);
                    } else {
                        logger.error("创建目录[" + subDirectory + "]失败");
                        changeWorkingDirectory(ftpClient, subDirectory);
                    }
                } else {
                    changeWorkingDirectory(ftpClient, subDirectory);
                }

                paths = paths + File.separator + subDirectory;
                start = end + 1;
                end = directory.indexOf(File.separator, start);
                // 检查所有目录是否创建完毕
                if (end <= start) {
                    break;
                }
            }
        }
        return success;
    }

    //判断ftp服务器文件是否存在
    public boolean existFile(FTPClient ftpClient, String path) throws IOException {
        boolean flag = false;
        FTPFile[] ftpFileArr = ftpClient.listFiles(path);
        if (ftpFileArr.length > 0) {
            flag = true;
        }
        return flag;
    }

    //创建目录
    public boolean makeDirectory(FTPClient ftpClient, String dir) {
        boolean flag = true;
        try {
            flag = ftpClient.makeDirectory(dir);
            if (flag) {
                logger.info("创建文件夹" + dir + " 成功!");

            } else {
                logger.info("创建文件夹" + dir + " 失败!");
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return flag;
    }

    /**
     * 下载文件 *
     *
     * @param pathName FTP服务器文件目录 *
     * @param pathName 下载文件的条件*
     * @return
     */
    public boolean downloadFile(FTPClient ftpClient, String pathName, String targetFileName, String localPath) {
        boolean flag = false;
        OutputStream os = null;
        try {
            System.out.println("开始下载文件");
            //切换FTP目录
            ftpClient.changeWorkingDirectory(pathName);
            ftpClient.enterLocalPassiveMode();
            FTPFile[] ftpFiles = ftpClient.listFiles();
            for (FTPFile file : ftpFiles) {
                String ftpFileName = file.getName();
                if (targetFileName.equalsIgnoreCase(ftpFileName.substring(0, ftpFileName.indexOf(".")))) {
                    File localFile = new File(localPath);
                    os = new FileOutputStream(localFile);
                    ftpClient.retrieveFile(file.getName(), os);
                    os.close();
                }
            }
            ftpClient.logout();
            flag = true;
            logger.info("下载文件成功");
        } catch (Exception e) {
            logger.error("下载文件失败");
            logger.error(e.getMessage(), e);
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    logger.error(e.getMessage(), e);
                }
            }
            if (null != os) {
                try {
                    os.close();
                } catch (IOException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        return flag;
    }

    /*下载文件*/
    public InputStream download(String ftpFile, FTPClient ftpClient) throws IOException {
        String servicePath = String.format("%s%s%s", basePath, "/", ftpFile);
        logger.info("【从文件服务器获取文件流】ftpFile : " + ftpFile);
        if (Utils.isEmpty(servicePath)) {
            throw new RuntimeException("【参数ftpFile为空】");
        }
        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        ftpClient.enterLocalPassiveMode();
        ftpFile = new String(servicePath.getBytes("utf-8"), "iso-8859-1");
        return ftpClient.retrieveFileStream(ftpFile);
    }

    /**
     * 删除文件 *
     *
     * @param pathname FTP服务器保存目录 *
     * @param filename 要删除的文件名称 *
     * @return
     */
    public boolean deleteFile(String pathname, String filename) {
        boolean flag = false;
        FTPClient ftpClient = getFtpClient();
        try {
            logger.info("开始删除文件");
            if (ftpClient.isConnected()) {
                //切换FTP目录
                ftpClient.changeWorkingDirectory(pathname);
                ftpClient.enterLocalPassiveMode();
                ftpClient.dele(filename);
                ftpClient.logout();
                flag = true;
                logger.info("删除文件成功");
            } else {
                logger.info("删除文件失败");

            }
        } catch (Exception e) {
            logger.error("删除文件失败");
            logger.error(e.getMessage(), e);
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        return flag;
    }

    public void closeFtpClient(FTPClient ftpClient) {
        if (ftpClient.isConnected()) {
            try {
                ftpClient.disconnect();
            } catch (IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    public InputStream downloadFile(String pathname, String filename) {
    	FTPClient ftpClient = getFtpClient();
    	String filePath = "company/3101051020110114/annexes_url";
        InputStream inputStream = null;
        try {
            System.out.println("开始下载文件");
            //切换FTP目录
            ftpClient.changeWorkingDirectory(filePath);
            ftpClient.enterLocalPassiveMode();
            FTPFile[] ftpFiles = ftpClient.listFiles();
            for (FTPFile file : ftpFiles) {
            	System.err.println(file.getName()+"file.getName()");
                if (filename.equalsIgnoreCase(file.getName())) {
                	System.err.println("找到文件了");
                    inputStream = ftpClient.retrieveFileStream(file.getName());
                    break;
                }
            }
            ftpClient.logout();
            logger.info("下载文件成功");
        } catch (Exception e) {
            logger.error("下载文件失败");
            logger.error(e.getMessage(), e);
        } finally {
            if (ftpClient.isConnected()) {
                try {
                    ftpClient.disconnect();
                } catch (IOException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        return inputStream;
    }
}


controller代码如下:

@RequestMapping(value = "/C20000009",method = RequestMethod.POST)
    public Result addPhotoToFTP(MultipartFile file,HttpServletRequest request){
		String path = request.getParameter("path");
		//给图片起一个新的名称,防止在图片名称重复
        String msg = "";
        int code = 0;
        if(file!=null){
            try {
            	//图片上传,调用ftp工具类 image 上传的文件夹名称,newname 图片名称,inputStream
                boolean hopson = ftpUtil.uploadFileToFtp(path, file.getOriginalFilename(), file.getInputStream());
                if(hopson) {
                	// 把图片信息存入到数据库中
                	msg = "上传成功";
                }
            } catch (Exception e) {
            	msg = "上传失败";
            	code = -1;
                e.printStackTrace();
            }
        }
		return Result.error(code, msg);
    }
	
	/**
	 * 功能代码  C20000010
	 * 功能名称 deletePhotoToFTP 
	 * 功能描述 删除FTP上的文件
	 * @return
	 */
	@RequestMapping(value = "/C20000010",method = RequestMethod.POST)
    public Result deletePhotoToFTP(@RequestBody Map<String, String> params){
		String path =  params.get("path");
		String filename =  params.get("fileName");
        String msg = "";
        int code = 0;
	    try {
	    	boolean result = ftpUtil.deleteFile(path, filename);
	        if (result) {
	           	msg = "删除成功";
	   		}else {
	   			msg = "删除失败";
	   	        code = -1;
	   		}
		} catch (Exception e) {
			msg = "删除失败";
		    code = -1;
		}
        
		return Result.error(code, msg);
    }

四:从ftp上下载文件到ftp

controller代码:

@RequestMapping(value = "/C20000012",method = { RequestMethod.POST }, produces = "application/json; charset=utf-8")
    @ResponseBody
    public Result downloadFileByFTP(@RequestBody Map<String, Object> params,HttpServletRequest request,HttpServletResponse response)throws Exception {
		String filePath = params.get("filePath").toString();
		String fileName = params.get("fileName").toString();
		String msg = "";
        int code = 0;
         //当文件路径为空
         if (Utils.isEmpty(filePath)) {
             throw new IOException("File'" + filePath + "'is empty");
         } else {
        	// 1.读取要下载的内容
        	 InputStream in = ftpUtil.downloadFile(filePath, fileName);
        	// 2. 告诉浏览器下载的方式以及一些设置
             // 解决文件名乱码问题,获取浏览器类型,转换对应文件名编码格式,IE要求文件名必须是utf-8, firefo要求是iso-8859-1编码
             String agent = request.getHeader("user-agent");
             if (agent.contains("FireFox")) {
            	 fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
             } else {
            	 fileName = URLEncoder.encode(fileName, "UTF-8");
             }
             // 设置下载文件的mineType,告诉浏览器下载文件类型
             String mineType = request.getServletContext().getMimeType(fileName);
             response.setContentType(mineType);
             // 设置一个响应头,无论是否被浏览器解析,都下载
             response.setHeader("Content-disposition", "attachment; filename=" + fileName);
             // 将要下载的文件内容通过输出流写到浏览器
        	 
        	 OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
        		//创建存放文件内容的数组
        		byte[] buff =new byte[1024];
        		//所读取的内容使用n来接收
        		int n;
        		//当没有读取完时,继续读取,循环
        		while((n=in.read(buff))!=-1){
        			//将字节数组的数据全部写入到输出流中
        			outputStream.write(buff,0,n);
        		}
        		//强制将缓存区的数据进行输出
        		outputStream.flush();
        		//关流
        		outputStream.close();
        		in.close();
         }
         return Result.error(code, msg);
		
	}

前端js代码:

 //下载企业附件
        previewfile(file){
        	var params = {
				     "filePath":file.url,
				     "fileName":file.name
			     }
			    return axios({
			          method: 'post',
			          url: baseURL+'api/C20000012',
			          data: params,
			          responseType:'blob'
			      }).then((response)=>{
			    	  console.log(response.data,"0000000000")
			    	  // 处理返回的文件流
			    	  const a = document.createElement('a');
		              const blob = new Blob([response.data]);
		              const blobUrl = window.URL.createObjectURL(blob);
		            	  download(blobUrl,file.name) ;
					}
					); 
        },
        download(blobUrl,fileName) {
          console.log(fileName,"3333333333333")
      	  const a = document.createElement('a');
      	  a.style.display = 'none';
      	  a.download = fileName;
      	  a.href = blobUrl;
      	  a.click();
      	},

 

【100%通过率】华为od机试C卷【出差 / 员工派遣】C++ 实现 某公司部门需要派遣员工去国外做项目。现在,代号为 x 的国家和代号为 y 的国家分别需要 cntx 名和 cnty 名员工部门每个员工有一个员工号 (1,2,3,......),工号连续,从 1开始。部长派遣员工的规则: 阅读详情

相关推荐

苹果开发者账号( Apple Developer)登录出现:你的 Apple ID 暂时不符合使用此应用程序的条件(您的apple账户不符合资格)

Apple开发对于新手来说确实可能会遇到各种问题,在遇到 Apple Developer 账号登录问题时,除了检查账号的安全性设置和协议确认外,还需要考虑账号的具体配置问题,比如主邮箱的设置。

Winter_Sun灬的博客 4142

spring boot使用nginx和ftp服务器实现图片上传下载(windows server)

本人使用的springboot为1.5.6版本&lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.5.6.RELEASE&lt;/ver...

youthshadows的博客 5017

ANSYS Fluent热边界条件避坑指南:为什么你的自然对流计算结果总出错?

本文深入剖析了在ANSYS Fluent中进行自然对流仿真时,导致计算结果出错或发散的核心原因与解决方案。重点解析了重力项与操作密度设置、Boussinesq与不可压缩理想气体模型的抉择、以及压力离散格式(推荐Body Force Weighted)这三大关键雷区,并结合电子机箱散热等实战案例,提供了一套稳定可靠的仿真设置流程与调试技巧。

weixin_28396629的博客 741

springboot+nginx+ftp实现文件(单文件或者多文件上传)

https://www.cnblogs.com/jacklovejia/p/7715977.html linux+nginx+ftp搭建文件服务器 单文件上传 1.加载jar包 <!-- 文件上传 --> <dependency> <groupId>commons-fileupload</groupId> <artif...

凄凉的小金鱼 733

基于STM32与HRTIM的四开关Buck-Boost双向DC-DC电源设计实战(附源码、仿真与设计解析)

本文详细介绍了基于STM32F334的HRTIM高分辨率定时器实现四开关Buck-Boost双向DC-DC电源的设计实战。通过精准的PWM控制、双环PID算法和智能模式切换逻辑,解决了电压震荡与效率优化等关键问题,并提供了完整的源码、PSIM仿真及参数计算,为高性能电源设计提供了实用参考。

7z8x2c4v6b9的博客 299

SQLite性能优化:从WAL模式到内存映射的深度解析

本文深入解析SQLite性能优化策略,重点介绍WAL模式和内存映射技术的应用。通过合理配置WAL日志、同步策略和事务批处理,SQLite的IO吞吐量可提升3-5倍。结合内存映射和缓存优化,性能可进一步提升至默认配置的50倍,适用于高并发读写场景。

weixin_29231027的博客 455

springboot项目通过nginx访问ftp服务器文件

项目中遇到的springboot项目访问ftp服务器图片、视频问题的,想在我自己服务器上重新部署一遍,然后发现,执行docker的时候报错了。注意: -v /app-data/ftp_home:/usr/share/nginx/ftproot 这个就是挂载ftp服务地方。打开我的电脑在文件栏输入:ftp://你的ip/,输入密码就可以登录linux服务器的ftp。百度一下解析的更全面,我这里只是因为docker没启动。然后启动nginx之后,直接访问:你的ip + ftp文件路径,就可以访问了。

qq_25445369的博客 1407

【MediaPipe实战】从零构建实时人脸关键点检测与表情分析系统

本文详细介绍了如何使用MediaPipe框架从零构建实时人脸关键点检测与表情分析系统。通过Python代码实现,系统能够精准检测468个3D人脸关键点,并实时分析用户表情,适用于智能交互应用。文章包含环境配置、核心实现、可视化技巧及性能优化等实战内容,帮助开发者快速掌握深度学习在计算机视觉中的应用。

weixin_30836759的博客 73

SpringBoot+Nginx实现文件上传和下载功能(下)

本文章主要讲springBoot实现文件上传的功能。如需查看nginx的操作请前往SpringBoot+Nginx实现文件上传和下载功能(上)_czxboys的博客-优快云博客在加入以下依赖: 2、配置sshd连接 编写配置属性映射类 application.yml的配置 3、配置JSch JSch对象的初始化配置 4、配置文件传输的服务层 ISftpService接口就不贴代码了,直接给impl实现接口 5、配置controller层 项目代码:czxboys / jsch-springboo

czxboys的博客 955

纳米尺度仿真软件:Quantum Espresso_(13).非线性光学性质计算

通过 Quantum Espresso,可以高效地计算材料的非线性光学性质,包括二阶和三阶非线性极化率。这些性质在许多现代技术中具有重要的应用价值。在准备输入文件时,需要详细描述系统的晶格结构和原子位置,选择合适的基组和赝势,并设置计算参数和微扰设置。通过优化计算参数和使用并行计算,可以提高计算效率和精度。最后,使用适当的工具进行结果分析和可视化,可以更好地理解材料的非线性光学行为。

kkchenjj的博客 1279

Android 自动亮度

/则需要从BrightnessConfigure类中读取两个数组源:config_autoBrightnessLevels和config_autoBrightnessDisplayValuesNits。) 或知道其在DisplayPowerController()构造的时候初始化的。曲线设置好了,就应该扔代码里跑起来,模型建起来了,这个过程是咋样的呢?//它将负责曲线的创建,自动背光值的计算等。通过搜索配置关键词(

Android 1487

springboot上传文件到Nginx代理的FTP文件服务器

上传文件 Controller层: //图片类型校验 @Value("${picture.pictureType}") private String pictureType;// pictureType: ^.+.(jpg|png|gif|webp)$ //图片大小校验 @Value("${file.limitSize}") private String pictureSize; /** * @author bobo * 上传图片信

开始的博客 1368

【考试大纲】中级多媒体应用设计师考试大纲

中级多媒体应用设计师考试大纲

邓邓子的博客 382

docker&springboot-快速搭建FTP-Image图片服务器

本章目的是讲解图片服务器及其运用的使用,主讲解个别要点,细节没有全列出来,如果是未搭建过相关服务的小白白,建议先去参考下其他健全的讲解内容,你所希望的搭建一套完整体系流程,本篇可能不太适合。 事先安装docker和docker-compose这里就不说了, 我们希望在nginx下能直接拉取图片,所以ftp的上传的映射路径要和nginx的映射路径一起,方便取图 直接展示拉取配置如下: vs...

Leopard锋的博客 1121

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

springboot上传下载文件(2)---搭建独立的文件服务器

哇!chrome的自动网页翻译,把这篇文章英文单词全部弄乱了,难受啊= = 本系列文章: springboot上传下载文件(1)(项目和文件资源放在同一个服务器上) springboot上传下载文件(2)---搭建独立的文件服务器 springboot上传下载文件(3)--java api 操作HDFS集群+集群配置 springboot上传下载文件(4)--上传下载工具类(已封装) ...

小牛呼噜噜的博客 2万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SpringBoot 上传图片及搭建图片服务器

我们平时在上传图片、文件的时候都会用到form表单进行上传,但是上传之后会跳转页面。这里我用第二种方式上传:采用Ajax 异步请求的方式。 1、后端接口设计 /** * 上传文件 * @param file * @return * @throws Exception */ ...

choutichui4401的博客 996

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Java实现把图片上传到图片服务器(nginx+vsftp)

Java实现把图片上传到图片服务器(nginx+vsftp) 2018.07.09 22:53 1730浏览 前言: 在我另一篇笔记中已经记载了如何用nginx + vsftp搭建图片服务器(请参考nginx + vsftp搭建图片服务器),并且用vsftp的客户端工具filezilla测试过已经可用。但是在开发中应该是把用户在前端页面提交的图片保存到图片服务器中,接下来就来实现这个功能。 需求:...

weixin_39159757的博客 1808

linux centeros7 使用frp映射公网IP至本地ftp(本地云存储) 并上传文件 nginx访问图片

1.本地Linux搭建ftp 1.1ftp安装 yum -y install vsftpd 1.2创建用户(操作ftp) 并设置密码 需要输入两次 useradd ftpUser passwd ftpUser 1.3为ftpUser设置主目录,并授权读加删改 cd /usr/local mkdir ftp_file usermod -d /usr/local/ftp_file ftpUser chown ftpUser:ftpUser ftp_file chmod 775 ftp_fi

hhppppppp的博客 822

springboot+ftp服务器上传图片推荐方案

关于前后端交互图片等二进制数据,我们在方案选择上无非要注重的是下面几点: 前端怎么传?后端怎么接收?接收要干什么?怎么保存?保存到哪?

m0_64106946的博客 322

java 图片服务器 上传_Java实现把图片上传到图片服务器(nginx+vsftp)

前言:在我另一篇笔记中已经记载了如何用nginx + vsftp搭建图片服务器(请参考nginx + vsftp搭建图片服务器),并且用vsftp的客户端工具filezilla测试过已经可用。但是在开发中应该是把用户在前端页面提交的图片保存到图片服务器中,接下来就来实现这个功能。点我下载源码。需求:用户在页面中上传一张图片,把图片保存到图片服务器,把图片的url保存到user表中,复制user表中...

weixin_39744894的博客 323

springboot借助sftp将文件上传到远端的nginx服务器中,然后将文件路径存进数据库

先看效果 demo比较粗糙,忽略其中的命名,图片也是随便找的。 这里的上传文件使用的commons-fileupload工具包实现文件上传。 pom文件的部分依赖如下: <!-- 文件上传组件 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifa

Irons_one的博客 2874

linux安装nginx并配置域名映射和图片服务器

环境:阿里云轻量级云服务器 操作系统:centos7 背景: 在上一篇博客阿里云服务器部署SpringBoot项目(mysql安装、服务部署)(https://blog.youkuaiyun.com/zwx19921215/article/details/97558985)中已成功发布了springboot 项目,但是只能通过ip地址和端口访问,不太友好,于是乎我又从阿里云购买了一个域名,通过nginx...

4091

图片上传至Linux中Nginx服务器中

代码 controller层: package zzdx.sh.controller; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import or

China_HaoZi的博客 1100

【SpringBoot】上传图片到Linux服务器(html+ajax+jquery+ftpclient+nginx)

最近在做毕业设计,需要做一个批量上传图片的功能。 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://mav...

开发学习工作日志 2万+

SpringBoot + Vue版本JEECMS框架FTP图片跨域显示完整解决方案

这个完整的SpringBoot + Vue版本的JEECMS框架FTP图片跨域显示解决方案,包含了前后端完整代码、组件封装、安全配置和部署方案,可以直接集成到现有的JEECMS项目中。

qq_35757427的博客 118

SpringBoot整合Nginx+Vsftp,完成文件上传

前面已经发过了Nginx+Vsftp实现Java文件的步骤,这里就不再累述,如需要,可以找上一个博客内容:https://blog.youkuaiyun.com/weixin_44889894/article/details/115751062 1,编写UploadController @Controller public class UploadController { @ResponseBody @RequestMapping(value = "/upload",produces = "multip

weixin_44889894的博客 225
上一篇: 前端数据类型转化——字符串转数组
下一篇: 利用freemarker模板导出单个word及多word压缩导出到浏览器下载
Return_KB
博客等级 码龄9年 23粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值