You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "David J. M. Karlsen (JIRA)" <ji...@apache.org> on 2014/12/30 19:55:14 UTC

[jira] [Commented] (CAMEL-8191) Charset is ignored for SFTP producer endpoints

    [ https://issues.apache.org/jira/browse/CAMEL-8191?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14261355#comment-14261355 ] 

David J. M. Karlsen commented on CAMEL-8191:
--------------------------------------------

I don't think the endpoint actually supports the charset option - it's just inherited by the more generic file component but not handled in the SFTP component itself.
The conversion actually happens before the sftp component.
Have a look at https://gist.github.com/davidkarlsen/19cb1c8af7a8c5bd249e where there are two alternative ways of solving this:
1) Giving the Exchange.CHARSET_NAME option (which will influence the converter) or
2) converting to a byte array yourself and choosing the conversion charset

> Charset is ignored for SFTP producer endpoints
> ----------------------------------------------
>
>                 Key: CAMEL-8191
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8191
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ftp
>    Affects Versions: 2.12.3, 2.14.1
>         Environment: vso@vso-desktop:/tmp$ uname -a
> Linux vso-desktop 3.13.0-43-generic #72~precise1-Ubuntu SMP Tue Dec 9 12:14:18 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
> vso@vso-desktop:/tmp$ java -version
> java version "1.7.0_65"
> OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.12.04.1)
> OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
> vso@vso-desktop:/tmp$ ssh -v
> OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
>            Reporter: Volodymyr Sobotovych
>              Labels: charset, sftp
>
> For SFTP producer endpoints option "charset" is ignored and the output file is created using platform-default charset (usually UTF-8). 
> The simple Spring context illustrates the issue:
> {code}
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans 
>        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>        http://camel.apache.org/schema/spring 
>        http://camel.apache.org/schema/spring/camel-spring.xsd">
>   <camelContext xmlns="http://camel.apache.org/schema/spring">
>     <route>
>       <from uri="stream:in?promptMessage=Enter something:" />
>       <to uri="sftp://localhost:22/vso/sandbox?charset=ISO-8859-1&amp;username=fake_sftp_user&amp;password=qwerty"/>
>     </route>
>   </camelContext>
> </beans>
> {code}
> This context defines a route that transfers the string entered by user via SFTP. If the user enters "Müller", I can see 7-byte message in the output directory (because "ü" is represented using 2 bytes in UTF-8). While it should be 6-byte message if the file was encoded in ISO-8859-1.
> This problem affects only SFTP endpoints. File and FTP endpoints treat the "charset" option correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)