My code uploads all images without a folder, and that's OK! But what does FTP need to do as images are sent to the path: "/storage/emulated/0/PicturesGRP/enviados";
, storing the uploaded images and avoiding to send an image again in the next upload, does anyone know how to do it?
public void uploadFile() {
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(FTP_HOST);
ftpClient.setSoTimeout(10000);
ftpClient.enterLocalPassiveMode();
if (ftpClient.login(FTP_USER, FTP_PASS)) {
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
final File folder = new File("/storage/emulated/0/PicturesGRP/");
ftpClient.changeWorkingDirectory( "/public_html/minas55/public/assets/os/3524/");
for (final File fileEntry : folder.listFiles()) {
try {
FileInputStream fs = new FileInputStream(fileEntry);
if (!fileEntry.isDirectory()) {
String fileName = fileEntry.getName();
ftpClient.storeFile(fileName, fs);
fs.close();
Toast.makeText(getApplicationContext(), "Sincronização com Sucesso !", Toast.LENGTH_SHORT).show();
String horarioSync2 = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy ").format(System.currentTimeMillis());
syncHorario.setText(horarioSync2);
}
} catch (Exception e) {
String horarioSync2 = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy ").format(System.currentTimeMillis());
syncHorario.setText(horarioSync2);
}
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}