Camel saves full http request but I want only attached file

人走茶凉 提交于 2019-12-02 16:28:24

问题


I have the following code base:

@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());
    }

}

I upload file using postman:

It is actually usual csv.

But when I open file my application stored - I see file with following content:

Obvious that file contains full request information.

How can I save only file without other data from http request?

P.S.

I tried to register callback:

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

but it returns null

来源:https://stackoverflow.com/questions/46930494/camel-saves-full-http-request-but-i-want-only-attached-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!