Speed up recursively listing FTP files
Asked Answered
P

1

8

I have an Android app that lists folders and files of a FTP directory. I use Apache Commons FTP Client. It comes down to this line which I call for every folder

FTPFile[] folderElements = ftpClient.listFiles(folderName);

Works fine but is very time consuming. The whole task (getting all files and folders) takes about a minute. Can I speed that up somehow?

I already tried

ftpClient.setBufferSize(1024000);
Premaxilla answered 30/11, 2017 at 15:27 Comment(7)
The only way to speed it up, is using multiple parallel connections.Layton
Does one call take a minute?Baton
No: The whole task (getting all files and folders) takes about a minutePremaxilla
What's the purpose of your bounty? Do you expect some new approach (apart from parallelization as suggested already)? Or do you expect someone to code it for you?Layton
@MartinPrikryl: Every bounty has a description. So does mine. And I don't expect anything in particular.Premaxilla
Is the FTP directory on the mobile device?Physostomous
No, on a server.Premaxilla
G
2

my project might be a help. https://github.com/Honwhy/commons-pool-ftp (see ftpcp branch)

FTPCPManager ftpCPManager = new FTPCPManager();
ftpCPManager.setUrl("ftp://127.0.0.1");
ftpCPManager.setUsername("sa");
ftpCPManager.setPassword("sa");
ftpCPManager.setKeepAliveTimeout(1 * 60);

ftpCPManager.setConnectTimeout(1 * 1000);
ftpCPManager.setMaxWait(1 * 1000);

CommonFAOSupport support = new CommonFAOSupport(ftpCPManager);

support.downloadDirectory("/apps/data/ftp/download", 4000, 10, processService); //10 thread
Grecize answered 30/1, 2018 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.