Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.8k views
in Java FTP by (120 points)
Hi,

If have a remark about the existing FileTransferClient.java class.

In my application i have an array of bytes that i need to ftp to a server and provide the user with feedback about the progress.

One can do that with the getUploadStream method but then the eventlistener does not work, at least the bytes transferred part.

It only reports once the whole file is tranferred.

Since it's a file that's transferred over a slow network i need a progressbar for the user.

The only way arround this (that i've found) is to add the following to the FileTranfserClient class.

public synchronized String uploadBytes(byte[] content, String remoteFileName, WriteMode writeMode) throws FTPException, IOException {
        checkTransferSettings();
        boolean append = false;
        if (writeMode.equals(WriteMode.RESUME)) {
            ftpClient.resume();
        } else if (writeMode.equals(WriteMode.APPEND)) {
            append = true;
        }
        return ftpClient.put(content, remoteFileName, append);
    }


    public synchronized String uploadBytes(byte[] content, String remoteFileName) throws FTPException, IOException {
        return uploadBytes(content, remoteFileName, WriteMode.OVERWRITE);
    }


Perhaps this is something that should be added to this class.

Or is there an other method that i'm not aware of?

1 Answer

0 votes
by (162k points)
FileTransferClient.uploadStream supports the bytes transferred notifications.

Categories

...