I m using Apache FTPClient
. I was a do a copy of file in a folder just like cp -p
, but from Java. How can I do that using 'sendCommand' method or will it be possible any other way? The rename
method moves the file but does not keep a backup copy.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
There's no standard way to duplicate a remote file over FTP protocol. Some FTP servers support proprietary or non-standard extensions for this though.
So if your are lucky that your server is ProFTPD with mod_copy module, you can use
FTP.sendCommand
to issue these two commands:The second possibility is that your server allows you to execute arbitrary shell commands. This is not common either. If your server supports this you can use
SITE EXEC
command:Another workaround is to open a second connection to the FTP server and make the server upload the file to itself by piping a passive mode data connection to an active mode data connection. Implementation of this solution in PHP is shown in FTP copy a file to another place in same FTP.
If neither of this works, all you can do is to download the file to a local temporary location and re-upload it back to the target location.
See also: