我有以下代码库:
@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());
}
}
我使用邮递员上传文件:
它实际上是通常的 csv。
但是当我打开我的应用程序存储的文件时 - 我看到具有以下内容的文件:
显然该文件包含完整的请求信息。
如何仅保存文件而不保存来自 http 请求的其他数据?
附言
我试图注册回调:
@Override
public void process(Exchange exchange) throws Exception {
System.out.println(exchange);
final MultipartFile mandatoryBody = exchange.getIn().getBody(MultipartFile.class);
但它返回null