Java 如何申请<;base64编码器变压器/>;关于Mule中的message.OutboundAttachment

Java 如何申请<;base64编码器变压器/>;关于Mule中的message.OutboundAttachment,java,mule,mule-studio,mule-el,mule-component,Java,Mule,Mule Studio,Mule El,Mule Component,我有一个Base64二进制编码文件(例如:pdf、img、doc)。在Mule中,我将此编码数据设置为outBoundAttachment,以便最终使用SMTP将其作为附件发送。如何解码或仅将解码转换器应用于出站附件并在smtp中发送 <set-attachment attachmentName="xml.pdf" value="#[flowVars['pdf']]" contentType="application/pdf" doc:name="Attachment"/> <

我有一个Base64二进制编码文件(例如:pdf、img、doc)。在Mule中,我将此编码数据设置为outBoundAttachment,以便最终使用SMTP将其作为附件发送。如何解码或仅将解码转换器应用于出站附件并在smtp中发送

<set-attachment attachmentName="xml.pdf" value="#[flowVars['pdf']]" contentType="application/pdf" doc:name="Attachment"/>
<base64-decoder-transformer />
<string-to-byte-array-transformer />
<smtp:outbound-endpoint host="smtp.gmail.com" user="${username}" password="${pwd}"  connector-ref="smtpConnector" to="${toAddress}"  from="${fromAddress}" mimeType="text/html" subject="This is sample from mule"   responseTimeout="10000" doc:name="SMTP">
 <email:object-to-mime-transformer useOutboundAttachments="true"/>
 </smtp:outbound-endpoint> 

大多数转换器仅在消息的有效负载上工作。要将其应用于属性或变量,可以使用enricher,并在将变量作为属性添加回去之前,先将其作为有效负载。这样就不会覆盖原始有效负载。例如:

   <enricher target="#[flowVars.myvar]">
      <processor-chain>
         <set-payload value="#[flowVars.myvar]" />
         <base64-decoder-transformer />
      </processor-chain>
   </enricher>


此处提供有关充实的详细信息:

enricher内部不工作。它给出了“发现以元素'enrich'开头的无效内容。应为“{”、“,”、“}”之一。”抱歉,已更新正确配置的答案。忘了处理器链你太棒了!你能告诉我如何快速学习骡子吗?现场答案+1
   <enricher target="#[flowVars.myvar]">
      <processor-chain>
         <set-payload value="#[flowVars.myvar]" />
         <base64-decoder-transformer />
      </processor-chain>
   </enricher>