【发布时间】:2018-09-19 11:18:29
【问题描述】:
在我的骆驼路线中,我正在尝试获取文件对象。
rest("/file")
.post("/extract")
.to("direct:extract");
from("direct:extract")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
File file = exchange.getIn().getBody(File.class);
LOG.info("file : "+file);
multipartEntityBuilder.addPart("file", new FileBody(file, ContentType.MULTIPART_FORM_DATA,filename));
}
})
在这里,我从休息中发送文件,在处理器中,当我试图通过交换 getBody 时,我得到了 null。 但是如果我尝试获取 Inputstream 并且 byte[] 意味着它工作正常,同样的事情。
byte[] bytes = exchange.getIn().getBody(byte[].class);
LOG.info("bytes : "+bytes);
InputStream is = exchange.getIn().getBody(InputStream.class);
我的目标是从 Exchange getBody 获取文件对象,有什么问题请告诉我。
【问题讨论】:
标签: apache-camel apache-httpcomponents