WSO2 ESB - writing files out of base64

大兔子大兔子 提交于 2019-12-04 05:29:18

问题


I have a proxy which accepts XML files with Base64 encoded files in it. For example the XML looks like:

<message>
  <content>Hello World</content>
  <attachements>
     <attachement>*Base64 code here*</attachement>
     <attachement>*Base64 code here*</attachement>
     <attachement>*Base64 code here*</attachement>
  </attachements>
</message>

My Problem: I like to save the decoded files from the message into a folder of the filesystem of the server running the ESB. But how can I do this? If I encode a simple text like "Hello World" with Base64 I can decode it with an Script Mediator and Javascript, but how can I write a file to the filesystem? Do I have to write my own Mediator or is there another solution I don't know?

Would be nice if you could help me :) I'm using the WSO2 ESB for my bachelor thesis. So I'm not a professional yet :)

Thank you


回答1:


You have several options,

  1. If file sizes are small, iterate through <attachments> and for each attachment, decode using the script mediator and write to a file with syntax like,

    <property name="transport.vfs.ReplyFileName"
              expression="expression-to-compute-file-name"
              scope="transport"/>
    <property action="set" name="OUT_ONLY" value="true"/>
    <send>
        <endpoint>
            <address uri="vfs:file:///home/user/test/out"/>
        </endpoint>
    </send>
    
  2. If the files are large then it's more efficient to write your own class mediator




回答2:


Send the files to an local filesystem . Use VFS proxy



来源:https://stackoverflow.com/questions/16961413/wso2-esb-writing-files-out-of-base64

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!