Reputation:
I wanted to zip a folder which has some files in it and which is present at ftp location. How I can zip folder at FTP location.
FTPClient ftp = new FTPClient();
ftp.connect(hostname);
ftp.login(user, pass);
ftp.changeWorkingDirectory("myfolder"); //I wanted to zip this "myfolder"
Thanks.
Upvotes: 1
Views: 4077
Reputation: 51
While the process of downloading the files, compressing them locally and uploading them will work exactly as you want, this can take a lot of time depending on your connection speed.
If you have SSH access to the machine, I'd highly recommend making use of that. You can use an SSH library for Java (like SSHJ) and run a zip command on the folder. This will make the server zip the files locally, which will be much faster.
Upvotes: 3
Reputation: 340708
Look at the list of FTP protocol commands - there is nothing about ZIP there. And FTPClient
can only do what FTP protocol can. What you have to do is:
Of course you can wrap this in a pseudo-FTP command in your code/library.
Upvotes: 0
Reputation: 24780
FTP only deals with File Transfer. So, you can download or upload a file, but nothing more. If you want do zip something, you will have to download it to a machine your control and zip it there. Alternatively, you can use other protocols to access the machine (ssh / remote desktop / telnet / whatever you implement) and zip it remotely, but that will not be through FTP.
Upvotes: 0