我正在尝试使用Apache Camel与Google Drive进行通信 . 我已经为我的项目设置了Google的API,一切正常,除非我尝试将文件上传到我的GDrive,文件是空的 . 这是我的代码:
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
GoogleDriveConfiguration configuration = new GoogleDriveConfiguration();
configuration.setApplicationName("camel-drive");
configuration.setClientSecret("...");
configuration.setClientId("...");
configuration.setAccessToken("...");
configuration.setRefreshToken("...");
GoogleDriveComponent googleDriveComponent = new GoogleDriveComponent();
googleDriveComponent.setConfiguration(configuration);
context.addComponent("google-drive", googleDriveComponent);
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:data/inbox?noop=true")
.to("google-drive://drive-files/insert?inBody=content");
}
});
context.start();
Thread.sleep(20000);
context.stop();
}
我的理解是,在阅读了Google _258652的文档后,Camel组件需要 content
和 mediaContent
参数 . content
应该包含文件元数据,例如名称和文件类型,而 mediaContent
应该包括,据我所知,该文件的实际内容 .
现在,这个Camel组件还允许一个特殊的URI选项 inBody
,它告诉 endpoints 在交换机体内搜索指定的选项 .
这就是我所做的......如果我将'mediaContent'指定为inBody,则该文件甚至不会上传 .
这里有什么我想念的吗?