I have to upload a file to an FTP server. The filename contains special letters, say äöü
. On the FTP server, I need the filename to be UTF-8 encoded.
My code is like this:
import org.apache.commons.net.ftp.FTPClient;
FTPClient client = new FTPClient();
...
boolean retval = client.storeFile(fileName, inputStream);
The problem is that after storeFile
, the name of the file saved on the FTP server is ISO-8859-1 encoded rather than UTF-8.
How can I tell FTPClient
to UTF-8 encode the file names?
FEAT
command that it even supports UTF-8 (see RFC 2640, though not all servers support that spec). Some servers require clients to send non-standardOPTS UTF8 ON
orOPTS UTF-8 NLST
commands to activate UTF-8. So that is the $1M question - what doesFTPClient
support, and what does the server support? I would use a packet sniffer, like WareShark, to watch the FTP traffic and see. – Peroration