Codeguy007
Codeguy007

Reputation: 891

Multiple threaded ftp upload

I am trying to understand how to use ftp4j to do a multiple threaded upload. From the documentation it says that I can use multiple connections to upload different pieces of the file but how do I control what order they get reassembled on the server? They suggest using this listener but I am not sure what I can do in that completed method to help Stitch the file back together. They do mention ftp append but that only helps if I can control the order that they they finish or are appended.

import it.sauronsoftware.ftp4j.FTPDataTransferListener;

public class MyTransferListener implements FTPDataTransferListener {

    public void started() {
        // Transfer started
    }

    public void transferred(int length) {
        // Yet other length bytes has been transferred since the last time this
        // method was called
    }

    public void completed() {
        // Transfer completed
    }

    public void aborted() {
        // Transfer aborted
    }

    public void failed() {
        // Transfer failed
    }

}

Upvotes: 2

Views: 400

Answers (1)

batman
batman

Reputation: 90

Create two or more threads in Java and run them on different CPU threads. Then in all of those threads you created, upload your things you want to upload.

Edit: You can use zip libraries to split the file(s) and then reassemble them later

Upvotes: 1

Related Questions