以下是我的路由器类,我正试图上传视频文件并将其存储到一个文件位置。
SpringBootRouter.java
package com.camelrest;
import java.util.HashMap;
import java.util.Map;
import org.apache.camel.component.restlet.RestletComponent;
import org.apache.camel.spring.boot.FatJarRouter;
import org.restlet.Component;
import org.restlet.ext.spring.SpringServerServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class MySpringBootRouter extends FatJarRouter {
@Autowired
private MultipartProcessor multipartProcessor;
@Override
public void configure() {
restConfiguration().component("restlet");
rest("/upload").post().to("direct:upload");
from("direct:upload")
.to("file://E:/RestTest");
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
SpringServerServlet serverServlet = new SpringServerServlet();
ServletRegistrationBean regBean = new ServletRegistrationBean(
serverServlet, "/rest/*");
Map<String, String> params = new HashMap<String, String>();
params.put("org.restlet.component", "restletComponent");
regBean.setInitParameters(params);
return regBean;
}
@Bean
public Component restletComponent() {
return new Component();
}
@Bean
public RestletComponent restletComponentService() {
return new RestletComponent(restletComponent());
}
}
我正在尝试使用Postman上传视频文件,如下屏幕截图所示:
我上传的文件内容被保存为具有由camel生成的随机驼峰ID的文件名
然而,我想要传递在正文中的文件名
SampleVideo_1280x720_10mb.mp4
作为文件名,并从正文中删除以下内容
----------------------------948281627232093197119960
Content-Disposition: form-data; name="file"; filename="SampleVideo_1280x720_10mb.mp4"
Content-Type: video/mp4
所以最终输出可以是使用在Postman上传时使用的文件名上传的视频。