-1

I'm trying to upload some files to a Local FTP server. The observable list has all the files, and are uploaded by looping the array I'm using the commons-net-3.6.jar Library.

The Directory and everything get's created but the images uploaded are corrupted.
Huge change in color (looks like an old static TV image with colors)
What am i doing wrong?

NOTE!
Something I noticed was that the sizes of file's are the same in KB but differs slightly by bytes.

    ObservableList<File> uploadFiles = FXCollections.observableArrayList();

    FTPClient client = new FTPClient();
    InputStream fis = null;

    FTPConnection con = new FTPConnection();
    con.readData();  //gets username and password

    uploadFiles  = Something.getFiles(); //Gets Files

    try {
        client.connect(con.getServerIp());
        client.login(con.getUsername(), con.getPassword());

        String pathname = getPathname();

        client.makeDirectory(pathname);


        for (int i = 0; i < uploadFiles.size(); i++) {


            fis = new FileInputStream(uploadFiles.get(i)); 
            String filename = uploadFiles.get(i).getName();

            String uploadpath = pathname+"/"+filename;
            System.out.println("Uploading File : " + uploadpath);
            client.storeFile(uploadpath, fis);



        }



        client.logout();
    } catch (IOException e) {
        e.printStackTrace();




    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
            client.disconnect();
        } catch (IOException e) {

            e.printStackTrace();

        }
    }

output image sample

user8222166
  • 69
  • 1
  • 8

1 Answers1

0

Setting the file type to Binary did the Trick!

client.setFileType(FTP.BINARY_FILE_TYPE);
user8222166
  • 69
  • 1
  • 8