Camel保存完整的http请求,但我只想附加文件

时间:2017-10-25 10:52:14

标签: java rest upload apache-camel spring-camel

我有以下代码库:

@Component
public class DummyRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {

        rest("/upload").post().to("file://rest_files");
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        SpringServerServlet serverServlet = new SpringServerServlet();
        ServletRegistrationBean regBean = new ServletRegistrationBean( serverServlet, "/rest/*");
        Map<String,String> params = new HashMap<>();
        params.put("org.restlet.component", "restletComponent");
        regBean.setInitParameters(params);
        return regBean;
    }


    @Bean
    public org.restlet.Component restletComponent() {
        return new org.restlet.Component();
    }

    @Bean
    public RestletComponent restletComponentService() {
        return new RestletComponent(restletComponent());
    }

}

我使用邮递员上传文件:

enter image description here

实际上通常是csv。

但是当我打开文件我的应用程序存储时 - 我看到文件包含以下内容:

enter image description here

很明显该文件包含完整的请求信息。

如何只保存没有来自http请求的其他数据的文件?

P.S。

我尝试注册回调:

 @Override
 public void process(Exchange exchange) throws Exception {
     System.out.println(exchange);
     final MultipartFile mandatoryBody = exchange.getIn().getBody(MultipartFile.class);

但它会返回null

0 个答案:

没有答案