gpt4 book ai didi

apache-camel - Camel : "file" component, 但只将文件名作为正文传递

转载 作者:行者123 更新时间:2023-12-04 14:17:14 25 4
gpt4 key购买 nike

我正在尝试使用 Camel 处理潜在的大文件,并且担心它们“适合”在 Camel 的 body 中 Message .有没有一种方法可以将文件的名称(路径)作为消息正文传递,然后在处理器中使用它从磁盘读取?

最佳答案

您可以只传入一个 java.io.File 实例。这本质上是 Camel 文件组件自己做的事情(尽管它放置在 WrappedFile 中,因为与 ftp 组件共享代码)。

您当然也可以将文件名存储为字符串,然后从处理器访问文件,或者通过

String name = exchange.getIn().getBody(String.class);
File file = new File(name);
...
FileInputStream fis = new FileInputStream(file);
// read the file from the stream, etc.

关于apache-camel - Camel : "file" component, 但只将文件名作为正文传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9384102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com