Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.4k views
in Java FTP by (120 points)
Hi, we are having problem transfering PGP file using edtFTPj (free). The receiver cannot decrypt the transferred pgp file. But it can decrypt if we manually ftp the same pgp file. We also tried to use FTPTransferType.BINARY, but it did not work either.

maybe we should use streaming? Please help! thank you so much!!!


here is our code:
public static void ftp(String host, String user, String password, String data, String path,
String fileName) throws Exception
{
logger.info("-->Starting to ftp " + fileName);
FTPClient ftp = new FTPClient();
ftp.setRemoteHost(host);
// ftp.setRemotePort(21);
ftp.connect();
ftp.login(user, password);
ftp.setType(FTPTransferType.ASCII);
ftp.chdir(path);
ftp.put(data.getBytes(), fileName);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.quit();
logger.info("-->Finished ftping " + fileName);
}

public static void ftpFile(String host, String user, String password, String origFileFullName, String path,
String fileName) throws Exception
{
ftp(host, user, password, readFile(origFileFullName), path, fileName);
}

1 Answer

0 votes
by (162k points)
You must use FTPTransferType.BINARY. ASCII will not work.

And using the data as a Java string and performing getBytes() is unlikely to work either - Java strings use char sets.

Why don't you just upload the file using put(localfilename, remotefilename)?

Categories

...