SFTP下载客户端[单用户多线程、限速、取消、断点续传]

单session多channel的sftp多线程并发下载 依赖 <!--sFTP连接--> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.53</version> </dependency> import com.jcraft.jsch.*; 连接 使用ThreadLocal管理channel,确... 阅读详情
采用JSCH API(本例引用了jsch-0.1.52.jar)
官网参考 http://www.jcraft.com/jsch/

1,建立Session,对应一个用户账户,并在无传输线程时自动关闭session

public class SFTPProcessor2 {

	private static final Logger LOGGER = Logger.getLogger(SFTPProcessor2.class);

	private static Session session = null;

	

	public Session getConnect(Map<String, String> serverMap) {
		String ftpHost = serverMap.get(SFTPConstants.SFTP_SERVER_HOST);
		String port = serverMap.get(SFTPConstants.SFTP_SERVER_PORT);
		String ftpUserName = serverMap.get(SFTPConstants.SFTP_SERVER_USERNAME);
		String ftpPassword = serverMap.get(SFTPConstants.SFTP_SERVER_PASSWORD);

		// 默认的端口22 此处我是定义到常量类中;
		int ftpPort = SFTPConstants.SFTP_DEFAULT_PORT;

		// 判断端口号是否为空,如果不为空,则赋值
		if (port != null && !port.equals("")) {
			ftpPort = Integer.valueOf(port);
		}
		JSch jsch = new JSch(); // 创建JSch对象
		// 按照用户名,主机ip,端口获取一个Session对象
		try {
			session = jsch.getSession(ftpUserName, ftpHost, ftpPort);
						
			LOGGER.debug("Session created.");
			if (ftpPassword != null) {
				session.setPassword(ftpPassword); // 设置密码
			}

			// 具体config中需要配置那些内容,请参照sshd服务器的配置文件/etc/ssh/sshd_config的配置
			Properties config = new Properties();

			// 设置不用检查hostKey
			// 如果设置成“yes”,ssh就会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,
			// 并且一旦计算机的密匙发生了变化,就拒绝连接。
			config.put("StrictHostKeyChecking", "no");

			// UseDNS指定,sshd的是否应该看远程主机名,检查解析主机名的远程IP地址映射到相同的IP地址。
			// 默认值是 “yes” 此处是由于我们SFTP服务器的DNS解析有问题,则把UseDNS设置为“no”
			config.put("UseDNS", "no");

			session.setConfig(config); // 为Session对象设置properties
			
			session.setTimeout(SFTPConstants.SFTP_DEFAULT_TIMEOUT); // 设置timeout时候
			session.connect(); // 经由过程Session建树链接
			LOGGER.debug("Session connected.");
			
		} catch (JSchException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return session;
	}
	
/*	public boolean upfile(InputStream is, OutputStream os) throws IOException{
		boolean res = false;
		byte[] b = new byte[1024*1024*100];
		int read;
		if(os!=null){			
			do {
                read = is.read(b, 0, b.length);
                if (read > 0) {
                    os.write(b, 0, read);
                }
                os.flush();
            } while (read >= 0);			
		}		
		return res;
	}*/
	
/*	public void uploadFile(String localFile, String newName,
			String remoteFoldPath) // throws AppBizException
	{
		InputStream input = null;
		OutputStream os = null;
		try {
			File lf = new File(localFile);
			input = new FileInputStream(lf);
			// 改变当前路径到指定路径
			channel.cd(remoteFoldPath);
			long t1 = System.currentTimeMillis();
			//channel.put(input, newName);
			
			os = channel.put(newName
					//, new ProgressMonitor(lf.length()) // 上传时不执行init()方法
					,new ProgressMonitorByBytes(lf.length())
					,ChannelSftp.OVERWRITE) 
					
					;
			
			upfile(input,os);
			
			
			channel.put(localFile
					, newName
					, new ProgressMonitorByBytes()
					, ChannelSftp.OVERWRITE);
			
			
			
			System.out.println("Time elapsed: "  +  (System.currentTimeMillis() - t1) + "(ms)");
		} catch (Exception e) {
			LOGGER.error("Upload file error", e);
			
		} finally {
			if (input != null) {
				try {
					input.close();
				} catch (IOException e) {
					
				}
			}
			if (os != null) {
				try {
					os.close();
				} catch (IOException e) {
					
				}
			}
		}
	}*/



	public static void main(String[] args) throws Exception {
		SFTPProcessor2 ftpUtil = new SFTPProcessor2();
		Map<String, String> ftpServerMap = new HashMap<String, String>();
		ftpServerMap.put((String) SFTPConstants.SFTP_SERVER_HOST, "localhost");
		ftpServerMap.put((String) SFTPConstants.SFTP_SERVER_USERNAME, "name");
		ftpServerMap.put((String) SFTPConstants.SFTP_SERVER_PASSWORD, "password");
		ftpServerMap.put((String) SFTPConstants.SFTP_SERVER_PORT, "22");
		ftpUtil.getConnect(ftpServerMap);
		
		//ftpUtil.uploadFile("e:/eclipse-jee.zip", "eclipse-jee.zip", System.getProperty("file.separator"));		
		
		String rf1 = "eclipse-jee.zip";
		String rp1 = System.getProperty("file.separator")+"d";
		//String rp1 = "";
		String rf2 = "zzzz.zip";
		String rp2 = System.getProperty("file.separator")+"d";
		//String rp2 = "";
		String lf1 = "e:/yyyy.zip";
		String lf2 = "e:/zzzz.zip" ;
					
		
		DownLoadThread d1 = new DownLoadThread(session,rf1,rp1,lf1,
				ftpServerMap.get((String) SFTPConstants.SFTP_SERVER_HOST),
				ftpServerMap.get((String) SFTPConstants.SFTP_SERVER_USERNAME),
				"TRANS100");
		DownLoadThread d2 = new DownLoadThread(session,rf2,rp2,lf2,
				ftpServerMap.get((String) SFTPConstants.SFTP_SERVER_HOST),
				ftpServerMap.get((String) SFTPConstants.SFTP_SERVER_USERNAME),
				"TRANS99");
		final Thread t1 = new Thread(d1);
		final Thread t2 = new Thread(d2);
		t1.start();
		t2.start();

		final List<Thread> lst = new ArrayList<Thread>();
		lst.add(t1);
		lst.add(t2);
		
		//ftpUtil.downloadFile("eclipse-jee.zip", System.getProperty("file.separator")+"d", "e:/zzzz.zip");
		//ftpUtil.downloadFile("snagit.zip", System.getProperty("file.separator")+"d", "e:/test20150608.zip");
		Thread t3 = new Thread(new Runnable(){
			@Override
			public void run() {
				while(true){
					boolean nonlive = true;
					for (int i = 0; i < lst.size(); i++) {
						if(lst.get(i).isAlive()){
							nonlive = false;
							break;
						}
					}
					if( nonlive ){
						System.out.println("No Active transmission, exit!");
						session.disconnect();
						break;
					}
				}
				
			}			
		});
		//t3.setDaemon(true);
		t3.start();
		

	}

}


2,建立通道,多线程下载
public  class DownLoadThread implements Runnable  {
	private static final Logger LOGGER = Logger.getLogger(SFTPProcessor2.class);
	private ChannelSftp channel = null;
	private Session session = null;
	private ProgressMonitorByBytes monitor = null;
	private String remotef = null;
	private String remotep = null;
	private String lf = null;
	private String ftpuser = null;
	private String ftphost = null;
	private String transid = null;
	
	public DownLoadThread(Session ss , String rf ,String rp, String lf ,String host, String user,String tid) {
		this.session = ss;
		//this.monitor = p;
		this.remotef = rf;
		this.remotep = rp;
		this.lf = lf;
		this.ftphost = host;
		this.ftpuser = user;
		this.transid = tid;
	}
	
	@Override
	public void run() {
		
		try {
			channel = getOpenCh(session,ftphost,ftpuser);
			monitor = new ProgressMonitorByBytes(transid,remotef,this.getRemoteFilesize1(channel,remotef,remotep));
			downloadFile(this.remotef,this.remotep,this.lf);
			closeChannel();
			
			//Thread.currentThread().interrupt();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public  ChannelSftp getOpenCh(Session ss ,String ftphost,String ftpusername){
		try {
			LOGGER.debug("Opening SFTP Channel.");
			channel = (ChannelSftp) ss.openChannel("sftp"); // 打开SFTP通道
			channel.connect(); // 建树SFTP通道的连接
			LOGGER.debug("Connected successfully to ftpHost = " + ftphost
					+ ",as ftpUserName = " + ftpusername + ", returning: "
					+ channel);
		} catch (JSchException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return channel;
	}
	
	public void closeChannel() 
	{
		try {
			if (channel != null) {
				channel.disconnect();
			}
		
		} catch (Exception e) {
			LOGGER.error("close sftp error", e);
			// throw new AppBizException(AppExcCodes.CLOSE_FTP_ERROR,
			// "close ftp error.");
		}
	}
	
	public void downloadFile(String remoteFile, String remotePath,String localFile) {
	
		OutputStream output = null;
		File file = null;
		
		try {
			file = new File(localFile);
			
			
			if (!checkFileExist(localFile)) {
				file.createNewFile();
				output = new FileOutputStream(file);
				channel.cd(remotePath);
				//channel.get(remoteFile, output);
				channel.get(remoteFile, localFile
					//, new ProgressMonitor(getRemoteFilesize1(channel,remoteFile,remotePath))
						,monitor
					, ChannelSftp.OVERWRITE);
				
			}else{
				//output = new FileOutputStream(file);
				channel.cd(remotePath);
				
				channel.get(remoteFile, localFile
					//, new ProgressMonitor(getRemoteFilesize1(channel,remoteFile,remotePath))
						,monitor
					, ChannelSftp.RESUME);
				
			}
			
						

		} catch (Exception e) {
			LOGGER.error("Download file error", e);
			
		} finally {
			if (output != null) {
				try {
					output.close();
				} catch (IOException e) {
					
				}
			}
			if (file != null) {
				//file.delete();
			}
		}
	}
	
	private boolean checkFileExist(String localPath) {
		File file = new File(localPath);
		return file.exists();
	}
	
	public long getRemoteFilesize1(ChannelSftp cf , String remoteFile,String remotepath ) {
		
		Object o =  null;
		long s = 0;
		try {
			Vector v =  cf.ls(cf.pwd() + "/" + remotepath + "/" +  remoteFile);
			if(v!=null && v.size() == 1){
				o = v.firstElement();
			}			
			//System.out.println();
			LsEntry  cl =  (LsEntry)o;	
			s = cl.getAttrs().getSize();
			System.out.println(s + "(bytes)");
		} catch (SftpException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return s;
	}
	

}

3,下载进度监控,控制取消,限制速度等

public class ProgressMonitorByBytes implements SftpProgressMonitor {

	private long transfered;
	private long filesize;	
	private String remotef;
	private Formatter f = null;
	private long stime;
	private long etime;
	private String transferID ;
	
	public ProgressMonitorByBytes(String transid,String remotefile,
			long totalsize
			) {
		this.filesize = totalsize;
		this.remotef = remotefile;
		this.transferID = transid  ;
	}

	
	public void sendmsg(){
		DecimalFormat df = new DecimalFormat( "#.##");
		String per = df.format(100*(1.0f*transfered/filesize));
        System.out.println("Currently transferred total size: " + transfered + " bytes, percent: " + per + "% [" + remotef + "]" );
        f.format("%1$10s\n","Currently transferred total size: " + transfered + " bytes, percent: " + per + "% [" + remotef + "] " );
	}
	
	@Override
	public boolean count(long count) {
		long now = System.currentTimeMillis();
		long timeelapse = (now - stime);
		boolean cancelCondition = (timeelapse > 10*1000) && "TRANS1000".equals(transferID);
		
		if(transfered != filesize   )   {
			sendmsg();
	        transfered = transfered + count;
	        if(cancelCondition){	//作为取消下载使用,可以取消(暂停下载)
	        	f.format("%1$10s\n","Cancel transfer: [" + remotef + "]");
	        	System.out.printf("%1$10s\n","Cancel transfer: [" + remotef + "]");
	        	return false;
	        }
	        
	        boolean sleepCondition = (1000 * (1.0d/1024) * transfered / timeelapse ) > 4096   ;
	        if(sleepCondition){
	        	try {
					Thread.currentThread().sleep(1000); //作为限速使用,貌似可以限制下载速度
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	        }
	        
	        return true;
	        
		}	
		
        
		return false;
	}

	@Override
	public void end() {
		etime = System.currentTimeMillis();
		sendmsg();
		System.out.println("Transferring done. [" + remotef + "]");
		f.format("%1$10s\n", "Transferring done. [" + remotef + "]");
		f.format("%1$10s\n", "Time Elapsed:"+ getTimePassed(etime - stime)  +" [" + remotef + "]");
		f.close();
		
	}
	
	public String getTimePassed(long times){
		String res = "";
		long hours = 0;
		long minutes = 0 ;
		long seconds = 0 ;
		long millseconds = 0;
		hours = times / (1000*60*60);
		minutes = (times - hours * (1000*60*60)) / (1000*60);
		seconds = (times - hours * (1000*60*60) - minutes*1000*60) / 1000;
		millseconds = times - hours * (1000*60*60) - minutes*1000*60 - seconds*1000;
		res = Long.toString(hours, 10)+"小时" + Long.toString(minutes, 10)+"分钟"+ Long.toString(seconds, 10)+"秒"+ Long.toString(millseconds, 10)+"毫秒";
		
		return res;
	}

	/**
	 * @param arg0	1:下载,0:上传
	 * @param arg1	原始文件PATH
	 * @param arg2	目标文件PATH
	 * @param arg3	文件大小
	 * 
	 * */	
	@Override
	public void init(int arg0, String arg1, String arg2, long arg3) {
		stime = System.currentTimeMillis();
		try {
			f = new Formatter(new FileOutputStream("E:/xdownlog.log", true));
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		f.format("%1$10s\n", "Transferring begin. [" + remotef + "]");
		//filesize = arg3;
		System.out.println("Transferring begin. [" + remotef + "]");
		System.out.println("======================");
		System.out.println(arg0);System.out.println(arg1);System.out.println(arg2);System.out.println(arg3);
		System.out.println("======================");
		

	}

}

4,配置用的常量

public class SFTPConstants {

	public static final int SFTP_DEFAULT_TIMEOUT = 0;
	public static final Object SFTP_SERVER_HOST = "SFTP_SERVER_HOST";
	public static final Object SFTP_SERVER_PORT = "SFTP_SERVER_PORT";
	public static final Object SFTP_SERVER_USERNAME = "SFTP_SERVER_USERNAME";
	public static final Object SFTP_SERVER_PASSWORD = "SFTP_SERVER_PASSWORD";
	public static final int SFTP_DEFAULT_PORT = 22;
	

}


FileZilla完全指南:从FTP/SFTP传文件到搭建自己的服务器 文件传输协议(FTP)是服务器运维和网站部署中最基础也最常用的手段之一,而SFTP依托SSH加密通道,在安全性和兼容性上更为突出。理解两者的区别与适用场景,是高效管理远程文件的前提。FileZilla作为免费开源的跨平台客户端/服务端软件,覆盖了从个人建站到企业运维的典型需求:通过站点管理器批量管理多台服务器,借助被动模式与端口放行解决连接难题,利用断点续传与队列控制保障大文件稳定传输。本文从连接协议选择、客户端实操,到服务端搭建与常见排错,系统梳理了这套工具链的完整用法,帮助你快速上手并形成长期高效的运维 阅读详情

相关推荐

群晖NAS间高速文件传输:SFTP协议优化与rsync实战指南

文件传输协议(FTP)及其安全版本SFTP(SSH File Transfer Protocol)是跨系统、跨设备数据迁移的基础网络协议,通过建立加密通道实现安全可靠的文件交换。其核心原理在于客户端与服务器间的认证、连接建立与数据流封装,尤其SFTP基于SSH协议,在单端口实现加密传输与完整会话管理。在数据备份、服务器迁移等应用场景中,协议的性能优化直接影响传输效率。本文聚焦于群晖NAS设备间的文件同步与迁移需求,针对海量文件传输场景,通过调整SSH缓冲区、加密算法及并发参数,结合rsync增量同步与lft

weixin_30487201的博客 368

C++多线程断点续传下载器:从原理到实战代码实现

多线程编程是提升程序并发性能的核心技术,其原理在于通过创建多个执行流并行处理任务,充分利用多核CPU的计算能力。在文件下载等I/O密集型场景中,多线程技术能显著减少网络等待时间,提升吞吐量。结合HTTP协议的Range请求头,可以实现文件的分块下载,这是断点续传功能的技术基础。将多线程与断点续传结合,能够构建出高效、可靠的下载工具,广泛应用于各类客户端软件和分布式系统中。本文以C++后端开发为背景,通过一个完整的实战案例,详细解析了如何设计一个支持多线程并发下载与断点续传的文件下载器,涵盖了线程同步、进度持

virusswb的专栏 418

FileZilla新手必看:从下载到连接FTP服务器的保姆级指南(Windows版)

本文提供FileZilla客户端的详细使用教程,涵盖从下载安装到连接FTP服务器的完整流程,特别针对Windows用户优化。内容包括安全配置、站点管理、文件传输技巧及常见问题解决方案,帮助新手快速掌握这一高效FTP工具。

weixin_29306571的博客 528

java jsch实现sftp文件上传,并且控制上传的速度,同时监控上传进度

工作中,有些环境带宽有限,比如说专线,通常带宽比较小,又不便宜,当业务量大的时间,如果在专线上还要传输文件的话,往往在文件传输的时间会导致带宽占慢,就有可能导致时实交易进不来,有可能影响交易,今天贴一下 jsch实现sftp文件上传,并且控制上传的速度,同时监控上传进度,供大家参考。maven 工程下先把jsch 依赖添加到pom.xml &lt;dependency&gt; ...

kevin的博客 9609

FileZilla实战指南:高效下载FTP公开数据集的完整流程

本文详细介绍了使用FileZilla高效下载FTP公开数据集的完整流程,包括软件安装、连接配置、文件筛选和传输优化等实用技巧。通过实战案例和常见问题解决方案,帮助用户快速掌握FTP数据集下载的核心方法,提升数据传输效率和稳定性。

weixin_26965807的博客 347

WindTerm:现代终端操作系统,统一SSH/SFTP/Serial/Telnet

终端工具是DevOps与嵌入式开发的基础交互界面,其核心能力涵盖协议通信、字符渲染、会话管理与输入控制。传统工具如PuTTY、Xshell和系统Terminal受限于协议割裂、渲染低效与会话孤立,难以支撑云服务器、IoT网关、ARM开发板等多协议协同场景。WindTerm以C/C+++Qt重构底层,实现SSH/SFTP/Serial/Telnet四协议统一栈,支持零拷贝传输、语义化渲染与可序列化会话,实测SFTP达247MB/s、串口自动适配PL2303/CH340等芯片。它不仅是高性能终端客户端,更是面向

weixin_30530339的博客 458

使用Renci.SshNet实现sftp文件上传和下载

使用Renci.SshNet实现sftp文件上传和下载

wuyb_2004的专栏 8802

gFTP 2.0.19 多协议文件传输实战:FTP/HTTP/SSH 3种协议配置与性能对比

本文详细解析了gFTP 2.0.19在多协议文件传输中的配置与性能优化,涵盖FTP、HTTP、SSH三种协议的实战设置与性能对比。通过实测数据展示不同协议在速度、CPU占用等方面的表现,并提供调优策略与自动化脚本示例,帮助用户提升文件传输效率与安全性。

weixin_30765577的博客 423

linux sftp限速,linux – SFTP文件限制

从sshd_config手册页:ChrootDirectorySpecifies a path to chroot(2) to after authentication. Thispath, and all its components, must be root-owned directories thatare not writable by any other user or group....

weixin_32429589的博客 1650

在摩尔线程 MTT S80 上使用 Ollama 进行 DeepSeek R1 蒸馏版模型推理

本文主要介绍了如何在摩尔线程 MTT S80 上通过 Ollama 快速完成DeepSeek R1 蒸馏系列模型的推理。

摩尔线程blog中心 3597

告别单一查询!MultiQueryRetriever在LangChain中的高级用法解析

本文深入解析了LangChain中的MultiQueryRetriever高级用法,该工具通过大语言模型自动生成多样化查询,显著提升文档检索的召回率和准确性。文章详细介绍了其核心机制、高级配置调优策略以及在多语言和专业领域中的实际应用,为开发者提供了优化知识库问答系统的实用方案。

weixin_28730927的博客 271

Python学习之——多线程断点续传下载器

manifest 顶层必须是 JSON 数组;每个元素必须是对象。当前实现采用白名单校验,未知字段直接报错。"urls": [],"url_digest": "SHA-256(用换行连接的 urls UTF-8 文本)",该摘要是 TaskStore 是否复用旧状态的精确比较对象。retriestimeoutrate_limitproxy和priority不属于summary;其中priority会在匹配旧摘要时覆盖更新,其他未包含字段的变化不会触发状态重置。状态含义当前写入来源实际可见后继。

selfsongs 340

滤波器设计实战:Filter Solutions软件从入门到精通

本文是Filter Solutions滤波器设计软件的实战指南,从入门到精通。通过设计一个低通数字滤波器的完整流程,详细讲解了参数设置、FIR/IIR选择、窗函数及逼近函数应用。文章重点介绍了如何利用这款经典工具高效完成滤波器设计、性能权衡,并将设计成果导出至MATLAB等平台进行实际验证与应用,是信号处理工程师提升效率的实用参考。

weixin_29095049的博客 531

《FileZilla全栈实操手册》(客户端+服务器端)

《FileZilla全栈操作手册》摘要:FileZilla是一款开源跨平台FTP/SFTP/FTPS文件传输工具,支持Windows/macOS/Linux系统。手册涵盖客户端与服务器端配置,包括安装指南、主界面功能说明、服务器连接方式(快速连接与站点管理器)、文件传输操作(上传/下载/批量处理)以及高级功能(断点续传/传输限速/同步浏览等)。特别提供服务器端安全设置建议,如用户权限管理、被动模式端口配置和IP过滤。适用于网站管理、远程备份等场景,支持100个文件同时传输的稳定操作。

DQzZzZ的博客 1068

BrainVision Recorder 和 BrainVision Analyzer 2.2 安装

本篇为《EEG处理》系列博客的第二篇,该系列博客主要记录EEG信号处理的学习过程中的软件安装和学习过程,方便以后查阅。本篇为BrainVision Recorder 和 BrainVision Analyzer 2.2 的安装过程。 BrainVision Recorder 和 BrainVision Analyzer 2.2 安装安装前奏Brain Vision Analyzer分析软件 安装Brain Vision Recorder记录软件 安装推荐几款个人使用的科研软件 安装前奏 Brain V

梁小憨憨的博客 5063

搭建适用于lammps中opls-aa力场的文件流程

现在我已经解决了以上问题,并且通过我的方法可以实现从空白文档到搭建完成以上全部内容,后期只要细心检查即可。需要的data文件最关键是获得相应阴阳离子的mmol文件,因此问题转化为构建一份mmol文件。主要用到的软件及程序:gaussian09,makemol程序(tranal),opls-aa的参数文件。二面角个数:成角原子序号及对应的参数(这里PF6的结构没有二面角,所以为0)参考文献个数:文献名(空够行数即可,这些是给自己的备忘))和自身体系对应的参考文献,修改或填入对应的参数即可。

baguette的博客 2886

SFTP与FTP协议对比及服务器搭建实战

文件传输协议(FTP)作为经典的网络协议,在安全性方面存在明显缺陷。现代安全文件传输通常采用基于SSH的SFTP协议,其通过加密通道和密钥认证机制实现安全传输。从技术原理看,SFTP将文件操作封装为SSH远程命令,天然具备完整的会话日志能力,特别适合金融等合规场景。实际部署时需要注意OpenSSH的Subsystem配置和ChrootDirectory权限设置,通过合理的目录结构和权限控制可避免常见连接错误。对于生产环境,建议禁用弱加密算法并调整TCP参数优化性能,配合inotify-tools实现文件变动

weixin_30243533的博客 440

小程序选项卡以及swiper套用(跨页面)

选项卡tab和swpier之间的套用 其实我之前写过一篇选项卡的切换demo,大家阔以参考一下 小程序多个选项卡切换 那今天写这个demo呢,是因为项目需求,所以仅供参考。 我是拿到了home.wxml的数组下标, 通过url传参的方式去将这个id传到下一个页面, 下一个页面接收以后再将id赋值给对应的tabI或者currentId(swiper 的下标) 实现上一个页面进来以后直接进入对应的页...

Rechal_Mei的博客 3597

Windows平台8款免费FTP/SFTP工具深度评测与选型指南

文件传输协议(FTP)及其加密衍生版本SFTP/FTPS,是计算机网络中用于在客户端和服务器之间传输文件的基础协议。其工作原理基于TCP连接,通过命令通道和数据通道实现文件的上传、下载和管理。在当今的开发和运维工作中,一个稳定高效的FTP客户端对于网站部署、数据备份、服务器管理至关重要,能显著提升文件传输的效率和可靠性。无论是个人开发者进行网站维护,还是系统管理员执行自动化脚本,选择合适的工具都直接影响工作流。本文聚焦Windows环境,针对**FileZilla**、**WinSCP**等热门工具,从稳定

weixin_28308325的博客 511

MATLAB 开发项目实例 1000 例专栏之第37例:基于Simulink的无人机飞行控制系统设计

通过上述项目实例,我们成功地使用Simulink设计和仿真了一个无人机的飞行控制系统。这个项目展示了从无人机建模、路径规划、控制器设计到仿真验证的完整流程。Simulink的可视化和模块化特性使得系统的建模和仿真更加直观和高效。

xiaoheshang_123的博客 163

Hermes Agent 常见报错排查与问题解决

Hermes Agent 常见报错排查指南 摘要 本文全面梳理了 Hermes Agent 使用过程中的10类常见报错,按阶段划分为安装期、运行期认证类、后端基础设施类和长任务执行类四大类,并提供了系统化的排查流程: 安装期问题:包括命令未找到和Python版本不兼容,主要检查PATH环境和Python版本是否符合要求 认证类问题:涉及API Key认证失败和速率限制,需要验证密钥配置和配额状态 基础设施问题:包含Docker报错、MCP连接失败和OAuth令牌过期,需检查相关服务状态 执行类问题:主要是上

简简单单Onlinezuozuo 1345

Linux服务器自建SFTP与FTP文件传输服务:从协议选型到安全部署

文件传输协议是网络数据交换的基础技术,其核心原理是通过客户端与服务器之间的连接通道实现可靠的文件上传与下载。在技术价值层面,自建文件传输服务提供了数据自主可控、传输过程可审计、以及与企业内部系统深度集成的能力。应用场景广泛覆盖了服务器日志备份、开发生产环境代码同步、跨团队文件共享以及敏感数据内部流转等需求。本文聚焦于在Linux环境下,通过对比FTP与SFTP协议的安全性与网络适应性,详细解析如何部署基于SSH的SFTP服务并配置Chroot Jail实现用户隔离,同时兼顾vsftpd的被动模式配置与防火墙

weixin_30765577的博客 341

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

鸿蒙 PC 开源应用移植实战:FtpNextClient (FileZilla 类) 适配全流程总结

本文介绍了如何将传统的FTP/FTPS/SFTP客户端(如FileZilla/WinSCP)迁移到鸿蒙PC/平板的HAP应用开发。核心思路是通过交叉编译生成OpenHarmony所需的静态库(libcurl、libssh2等),用CMake组织业务代码为两层结构,最终由DevEco Studio的ArkTS工程通过NAPI加载原生库并完成打包。文章对比了传统客户端与鸿蒙版本在架构、UI、协议实现等方面的差异,详细说明了代码结构布局,包括ArkTS侧UI实现、原生C/C++侧协议引擎,以及如何通过NAPI实现

逍遥鸿_HongFee 564

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Windows下FileZilla使用全攻略:下载、安装与常见故障排查

文件传输协议(FTP)是连接本地电脑与服务器进行数据交换的基础方式,但在Windows环境下,系统自带功能往往不够高效稳定。选择一款免费开源且跨平台的FTP客户端,可以大幅提升文件管理效率。FileZilla凭借直观的双栏界面、对SFTP/FTPS协议的支持以及断点续传、并发传输等实用特性,成为众多用户的首选工具。从官网正确下载安装包,避开来路不明的下载站,到配置主动/被动模式解决连接失败,再到处理中文文件名乱码、传输中断等高频问题,都是实际运维中的关键环节。围绕Windows平台下的FileZilla,梳

weixin_34268579的博客 282

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

linux命令调ftp限速,Linux下操作设置ftp普通账号和vip账号限速

ftp工作流程:ftp回话包含了两个通道,控制通道和数据通道,ftp的工作有两种模式,一种是主动模式,一种是被动模式,以ftpserver为参照物,主动模式,服务器主动连接客户端传输,被动模式,等待客户端的连接主动模式:ftp客户端连接到ftp服务器的21端口,发送用户名和密码,客户端随机开放一个端口(1024以上),发送PORT命令道ftp服务器,告诉服务器客户端采用主动模式并开放端口;ftp服...

weixin_39603132的博客 1126
上一篇: MYSQL简单存储过程创建和java中的调用
下一篇: web前端js绘制统计图表,访问数据库
johnsearcher
博客等级 码龄17年 12粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值