【问题标题】:Camel: Delete the file with Google DriveCamel:使用 Google Drive 删除文件
【发布时间】:2016-03-05 11:42:45
【问题描述】:

我无法理解 Apache Camel。我需要从 Google Drive 中删除一个文件。下面是我的代码。

私有静态列表范围 = Arrays.asList("https://www.googleapis.com/auth/drive.file");

public static void main(String[] args ) throws Exception 
{       
     CamelContext context = new DefaultCamelContext();  

        GoogleDriveConfiguration configuration = new GoogleDriveConfiguration();
        configuration.setApplicationName("camel");
        configuration.setClientId("..");
        configuration.setClientSecret("..");
        configuration.setScopes(scopes);
        configuration.setAccessToken("..");
        configuration.setRefreshToken("..");

        GoogleDriveComponent googleDriveComponent = new GoogleDriveComponent();
        googleDriveComponent.setConfiguration(configuration);
        context.addComponent("google-drive", googleDriveComponent);

        context.addRoutes(  
             new RouteBuilder()  
             {  
                @Override  
                public void configure() throws Exception  
                {  
                    from("google-drive://drive-files/delete?fileId=..").log(LoggingLevel.INFO, "${body}");   
                }  
             });  
          context.start();  
          Thread.sleep(10000);  
          context.stop();  
       }}

请教一些东西。我做错了什么?

堆栈跟踪:

org.apache.camel.RuntimeCamelException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found { “代码”:404, “错误”:[{ “域”:“全球”, “位置”:“文件”, “位置类型”:“其他”, "message" : "找不到文件:..", “原因”:“未找到” }], “消息”:“找不到文件:..” }

【问题讨论】:

  • camel 是关于集成,或帮助它们之间的各种系统的集成。虽然您可以使用骆驼 google-doc 组件,但如果您只想“删除 google doc 中的文件”,那么您可能应该使用其他东西。
  • 感谢您的建议!我的主要任务——对付骆驼。我想完成这个程序。

标签: google-drive-api apache-camel


【解决方案1】:

如果您必须使用骆驼而不是“来自”,我将在 1 次计时器上启动一条路线,路线的下一步将是我自己的类中的一个方法调用,它将接受文件名并将其从谷歌驱动器中删除然后记录响应。我同意@Jeremie B 的观点,您可能不应该使用骆驼来删除 1 个文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多