2017-04-30 7 views
2

Exchangeオブジェクトを既に持っているApache Camelでメール添付情報を取得するにはどうすればよいですか?Apache Camelで添付ファイル情報を取得

<dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-mail</artifactId> 
     <version>x.y.z</version> 
</dependency> 

とすでにExchangeオブジェクトがある場合、その後、あなたはこの試みることができる:

Message message = exchange.getIn(); 
    if (message.getAttachments().size() > 0) { 
     for (Map.Entry<String, DataHandler> entry : messageCopy.getAttachments().entrySet()) { 
      DataHandler dataHandler = entry.getValue(); 
      //get the document filename     
      String attchmentFilename = dataHandler.getName(); 
      String decodedFilename = MimeUtility.decodeText(attchmentFilename); 
      //get inputstream of attachment file 
      InputStream is = dataHandler.getInputStream();    
      //generic function for extracting attachment content 
      extractor(is); 
     } 
    } 

は、私が使用することをお勧めしますが、Mavenプロジェクトを持っている場合は

答えて

3

、あなたはこの依存関係を使用することができます添付ファイルの内容やその他の情報を取得するためのApache Tikaの内部エクストラクタ

関連する問題