I'm using the Apache FTPClient
library to manage the files of my web server. I noticed that when I for example upload my SQlite
database and then download it again afterwards, the file has changed. Why does this happen?
My code for uploading via FTP is as follows:
public boolean uploadDatabase() throws IOException
{
ftpClient.enterLocalPassiveMode();
ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
File databaseFile = new File(databaseFileName);
InputStream inputStream = new FileInputStream(databaseFile);
boolean uploadedSuccessfully = ftpClient.storeFile(remoteDatabaseLocation, inputStream);
inputStream.close();
return uploadedSuccessfully;
}
If I then download the file again and compare the MD5Sum
of the original and the downloaded one like with code from here, they differ. Whether I download the file using the browser or via some Java code doesn't matter so it's obvious that the FTP
upload is corrupt and not the download.
Like pointed out in this answer, I'm already setting the file transfer mode to binary so I'm surprised why some bytes are still "randomly" inserted into the file. I compared them using the Hex Editor HxD. The resulting file hashes always consistently mismatch.