1

I am making a FTP client using apache.commons.vfs and I want to add the copy and paste functionality for the files in the remote server.

I used the copyFrom method to copy the files:

destFile.copyFrom(srcFile, Selectors.SELECT_ALL)

The problem is that in this way the data goes from remote server to the FTP client and from there back to the remote server, making the copy speed very slow compared to copying them by the cp command.

Is there a way in apache.commons.vfs to do the copy using the host commands instead of network transfers?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Gnis
  • 11
  • 2
  • I do not know if it is possible with Apache Commons VFS. But note that even if it is, most SFTP and FTP servers do not allow this operation anyway. See [How can I copy/duplicate a file to another directory using SFTP?](https://stackoverflow.com/q/28089821/850848) + [FTP copy a file to another place in same FTP](https://stackoverflow.com/q/3808799/850848). For this reason, I'd not really expect the library to support such operation. – Martin Prikryl Oct 25 '22 at 12:05
  • VFS can for sure access the local filesystem. You'd just have to have the right file pointers before that. But how would VFS assume that a file `ftp://localhost/a.txt` is actually the same as `/var/www/htdocs/a.txt`? This is where I believe the concept breaks. – Queeg Oct 25 '22 at 12:12
  • If you're using commons-vfs, is there a reason why you can't use the existing FTP client from commons-net? – Rob Spoor Oct 25 '22 at 13:12

0 Answers0