我有以下代码:
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.restlet.RestletComponent;
import org.restlet.ext.spring.SpringServerServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Map;
import java.util.HashMap;
@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());
}
}
我使用邮递员加载文件,并将文件夹内的应用商店文件rest_files
但是文件的内容和它的名字看起来很奇怪。
文件名:ID-username-1508923387747-0-2
内容: