Apache Camel FTP File Name Non English Character Encoding Problem

180 views Asked by At

I am working on a ftp route that gets a file from one endpoint and moves to another. If file has non english characters like ö,ç,ğ etc. filename in the header wont be correct. But when saved to endpoint filename seems to fine. I believe this is because program and windows 10 uses different encodings. But I have no idea to how to fix it.

  • For example; the original file name is aslan çilek.txt becomes aslan çilek when the file enters the processor.

***EDIT

                    from(...)
                    .convertBodyTo(String.class, "UTF-8")
                        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange) throws 
                                Exception {
                                String fileName =exchange.getIn().getHeader(Exchange.FILE_NAME).toString();
                                String newFn = fileName.substring(0, fileName.indexOf('.')) + "_"
                                        + sdf.format(new Date()) + fileName.substring(fileName.indexOf('.'));
                                exchange.getIn().setHeader("CamelFileName", newFn);
                            }
                        })
                        .doTry()
                        .to(...)
                        .bean(x.class, "successfulLog(*,${file:name})")
                        .doCatch(Exception.class)
                        .bean(x.class, "failedLog(*,${file:name},${exception.message})");

convertBodyTo(String.class, "UTF-8") is added after the special character problem. With or without I still have the same problem.

0

There are 0 answers