Packing up files on my machine, sending it to a server, and unpacking it

Posted by MxyL on Programmers See other posts from Programmers or by MxyL
Published on 2014-06-05T18:13:05Z Indexed on 2014/06/05 21:40 UTC
Read the original article Hit count: 240

Filed under:
|
|

I am implementing a feature in my application that sends all files in a specified folder to a server.

I have the basic FTP transaction set up using Apache Commons FTPClient: it sets up a connection and transfers a file from one place to another. So I can simply loop over the directory and use this connection to transfer all the files.

However, this could be better. Rather than transferring each file one by one, it makes more sense to pack it up in a compressed archive and then send the whole file at once. Saves time and bandwidth, since these are just text files so they compress nicely.

So I would like to add automatic archive packing and unpacking. This is the workflow I have planned out, using zip compression:

  1. Zip all files in the folder
  2. Send the file over
  3. Unzip the files at its destination

1 and 2 are easy since the files are on the local machine, but I'm not sure how to accomplish the last step, when the files are now on a remote server.

What are my options? I have control over what I can put and run on the server. Perhaps it is not necessary to do the packing/unpacking myself?

© Programmers or respective owner

Related posts about java

Related posts about file-handling