java - Unzip file on SFTP Server -


i have connected remote server via ftp , put zip file using following code.

channelsftp.cd(sftpworkingdir + "/" + remotedestinationdir); file file = new file(localsourcetofile); log.info("transferring file: " + localsourcetofile + " "+ sftpworkingdir + "/" + remotedestinationdir); fileinputstream fis = new fileinputstream(file); channelsftp.put(fis, file.getname()); fis.close(); log.info("transfer successful"); 

now, want unzip file on server

it seems channelsftp doesn't support executing commands on server side. deals transfer of files. can use channelexec https://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/channelexec.html execute unzip /path/to/uploaded/file.zip.

alternatively, have job running on server side watches directory upload files , upzip uploaded zip-files automatically.


Comments