Corrupt xlsx file when uploading via Java FTP

0

I'm trying to upload a file via FTP, the excel file apparently is copying it correctly, but when I open it, it says it's corrupt.

Any ideas ??

public static void enviarArchivoFTP(String localFile, String hostFile) throws FileNotFoundException, IOException{
    //fis = new FileInputStream(localFile);
    BufferedInputStream buffIn = new BufferedInputStream(new FileInputStream(localFile));
    ftp.setFileType(FTP.BINARY_FILE_TYPE);
    ftp.enterLocalPassiveMode();

    if(ftp.storeFile(hostFile,buffIn))
        System.out.println("Envio correcto");
    else
        System.out.println("Error Envio");
    //fis.close();
    buffIn.close();
}
    
asked by Eragonz91 26.10.2016 в 01:56
source

1 answer

0

The posted code is correct, what was wrong is that the user did not have writing permission, I tried trying to copy a file in the folder and could not. Trying with another ftp that if I had permission worked well.

    
answered by 26.10.2016 в 21:14