2017-05-31 124 views
0

我也许有一个愚蠢的问题,但我怎么能从FTP服务器下载文件。 我使用路由骆驼下载文件

。从( “FTP:/测试@本地:21 /密码=测试”)。要( “文件:/ d:\\测试”)

我有错误:无法存储空身体。为什么?我读了几个例子我的错误在哪里?由于

编辑

我用的路线:

。从( “直接:XX”) 。从(” ftp://[email protected]:21/?password=test “)。为了 (” 文件:// d :\收件箱“);

和我有错误:

org.apache.camel.component.file.GenericFileOperationFailedException:无法写入空体文件:d:\收件箱\ XXXXXXX 在org.apache.camel.component .file.FileOperations.storeFile(FileOperations.java:237) at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277) at org.apache.camel.component.file.GenericFileProducer.processExchange (GenericFileProducer.java:165) at org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)

回答

1

这应该起作用。

.from("ftp://[email protected]:21/?password=test").to("file://d:\\test") 

我很确定从部分。但到了,你可能需要改变一点点(WRT '/'),因为我还没有在Windows工作

+0

我有同样的问题 – atoua

+0

首先,你正在使用ftp服务器上的'/'路径。确保这是正确的。 – pvpkiran

+0

是的这是正确的。我有3个文件。 我用'producer.sendBodyAndHeader(“direct:xx”,null,“a”,10)调用我的路由;' – atoua

0

添加参数 'allowNullBody = true' 可你TO文件端点

到( “文件:// d:\测试allowNullBody =真”)


如果你深入到源代码状态org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:237),你会看到相关GenericFileOperationFailedException发生在

  1. 身体交流是空
  2. allowNullBody设置为false

默认情况下,在allowNullBody生产的文件中Camel File Component '假' 的状态。您需要将其更改为'true'以允许存储空文件。