解压缩SFTP服务器上的文件 [英] Unzip file on SFTP Server

查看:1032
本文介绍了解压缩SFTP服务器上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已通过FTP连接到远程服务器,并使用以下代码放置了一些zip文件.

I have connected to my remote server via FTP and i put some zip file using following code.

channelSftp.cd(SFTPWORKINGDIR + "/" + remoteDestinationDir);
File file = new File(localSourceToFile);
LOG.info("Transferring file: " + localSourceToFile + " to "+ SFTPWORKINGDIR + "/" + remoteDestinationDir);
FileInputStream fis = new FileInputStream(file);
channelSftp.put(fis, file.getName());
fis.close();
LOG.info("Transfer successful");

现在,我想在服务器上解压缩文件

Now, I want to unzip file on server

推荐答案

似乎ChannelSftp不支持在服务器端执行命令.它主要处理文件的传输.您可以使用ChannelExec https://epaul.github.io/jsch -documentation/simple.javadoc/com/jcraft/jsch/ChannelExec.html 执行解压缩/path/to/uploaded/file.zip.

It seems that ChannelSftp doesn't support executing commands on the server side. It mainly deals with the transfer of files. You can use ChannelExec https://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/ChannelExec.html to execute unzip /path/to/uploaded/file.zip.

或者,您可以在服务器端运行一项作业,该作业监视您将文件上传到的目录并自动对所有上传的zip文件进行压缩.

Alternatively, you could have a job running on the server side which watches the directory you upload files to and upzip any uploaded zip-files automatically.

这篇关于解压缩SFTP服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆