简体   繁体   中英

how to upload a directory with sftp

I am building a java web based application. To upload a directory and the files in it from my user's client to my server machine I am using a client-side Java applet which supports only ftp.

How do I upload a directory full of files using sftp and java?

"Only ftp" will not do with "sftp". Either you need an sftp-applet or to have ftp enabled on your server.

Using SFTP is a good idea, because FTP suffers from some security problems.

You are going to need to find SFTP client classes to use in the Java client applet which you will provide to your users, in place of the FTP classes you use now.

And, you are going to need to install an SFTP server software package on your server hardware, so your client applet has something to which to connect. (It's possible your server hardware already has this package. In that case you need to activate it and configure it.)

Finally, you need to understand that SFTP and FTP don't really offer the primitive operation "upload a directory." Your client Java software will need to figure out how to upload all the files in the directory on your user's machine.

I'm using JSCH aip( Link ) for contributing sftp application. Jsch has no method helping upload directory, you can get all file path in the directory you want to download and then pass them to the upload method (put(....) in ChannelSftp class).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM