-1
My code uploads all images without folder, and it’s all OK! But what is it that needs to do FTP as images are uploaded to the path: "/storage/emulated/0/PicturesGRP/enviados";
, storing the uploaded images and avoiding sending an image again in the next upload, someone knows how to do?
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();
}
}
}
I need it to create on the Folder server at the time of FTP
– Ronaldo Amaral