camel-ftp:目标文件名编码错误

问题描述 投票:0回答:1

在windows 10上开发。使用Win10 IIS FTP服务器。创建骆驼上下文来传输 ftp 文件。中文文件传输出现问题。目标路径中文文件乱码。

我尝试在 from() 和 to() URI 中添加 charset(ios-8859-1, utf-8, gb2312 ...) 参数,但不起作用。

public void configure() throws Exception {
        try {
            from("ftp://127.0.0.1:2121?binary=true&charset=windows-1252&delay=5s&delete=true&passiveMode=true&recursive=true")
            .to("file://E:/ftp_copy/local?charset=utf-8")   
            .log("Downloaded file ${file:name} complete."); 
        } catch (Exception e) {
            throw e;
        }
    }

一些日志:

15:21:08.321 [Camel (camel-1) thread #1 - ftp://127.0.0.1:2121] DEBUG o.a.c.c.f.FileOperations - [writeFileByReaderWithCharset,462] - Using Reader to write file: E:\ftp_copy\local\ÖÐÎÄ°¦°¦.txt with charset: utf-8

15:21:08.322 [Camel (camel-1) thread #1 - ftp://127.0.0.1:2121] DEBUG o.a.c.c.f.GenericFileProducer - [writeFile,282] - Wrote [E:\ftp_copy\local\ÖÐÎÄ°¦°¦.txt] to [file://E:%5Cftp_copy%5Clocal?charset=utf-8]

15:21:08.324 [Camel (camel-1) thread #1 - ftp://127.0.0.1:2121] INFO  route1 - [log,159] - Downloaded file ÖÐÎÄ°¦°¦.txt complete.

15:21:08.325 [Camel (camel-1) thread #1 - ftp://127.0.0.1:2121] DEBUG o.a.c.c.f.GenericFileOnCompletion - [onCompletion,75] - Done processing file: RemoteFile[ÖÐÎÄ°¦°¦.txt] using exchange: Exchange[ID-LAPTOP-7L49H3A5-1548141666835-0-1]

15:21:08.325 [Camel (camel-1) thread #1 - ftp://127.0.0.1:2121] DEBUG o.a.c.c.f.r.FtpOperations - [deleteFile,232] - Deleting file: ÖÐÎÄ°¦°¦.txt
character-encoding apache-camel camel-ftp
1个回答
0
投票

尝试添加查询参数 ftpClient.autodetectUTF8=true

© www.soinside.com 2019 - 2024. All rights reserved.