Question

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

Was it helpful?

Solution

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

OTHER TIPS

Send the files to an local filesystem . Use VFS proxy

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top