On Tue, 19 Feb 2019 at 14:23, Walter Heestermans (TME)
<[email protected]> wrote:
>
> Using Commons Net 3.3
The current release is 3.6
Please try with that version, and if there is still a problem, feel
free to raise a JIRA issue.
> public boolean storeFileToFTPServer(FTPTransferDetails details, byte[] data,
> String fileName, int fileType){
> FTPClient ftpClient = new FTPClient();
> ftpClient.setConnectTimeout(5000);
> boolean completed = false;
> OutputStream outputStream = null;
> int attempts = 0;
> do {
> try {
> LOG.info(attempts+ ": connecting");
> ftpClient.connect(details.getHostname(), details.getPort());
> LOG.info(attempts + ": connected");
> ftpClient.login(details.getUsername(), details.getPassword());
> LOG.info(attempts+ ": logged in");
> ftpClient.enterLocalPassiveMode();
> ftpClient.setFileType(fileType); <<< We are using binary!!
> ftpClient.sendSiteCommand("UMASK 0");
> String secondRemoteFile = details.getDirectory() + File.separator +
> fileName;
>
> outputStream = ftpClient.storeFileStream(secondRemoteFile);
> LOG.info("writing stream");
> outputStream.write(data);
> outputStream.close();
> LOG.info("Stream closed");
> completed = ftpClient.completePendingCommand();
> if (completed) {
> LOG.info("File transfer successfully completed for " + fileName +
> ":Host=" + details.getHostname());
> break;
> } else if(attempts==MAX_ATTEMPTS-1){
> LOG.info("File transfer waiting to complete for " + fileName +
> ":Host=" + details.getHostname());
> return false;
> }
> }
> catch (Exception ex) {
> ....
>
> The above code is sued to FTP data in UTF-8 format, but some Turkish and
> Polish characters are not transferred correctly. What are possible causes of
> this?
>
> Met vriendelijke groet / With kind regards,
> Walter Heestermans
>
>
>
> This e-mail may contain confidential information. If you are not an addressee
> or otherwise authorised to receive this message, you should not use, copy,
> disclose or take any action based on this e-mail. If you have received this
> e-mail in error, please inform the sender promptly and delete this message
> and any attachments immediately.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]