WSO2 ESB - 从 base64 写入文件 [英] WSO2 ESB - writing files out of base64
问题描述
我有一个代理,它接受带有 Base64 编码文件的 XML 文件.例如 XML 看起来像:
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>
我的问题:我喜欢将消息中的解码文件保存到运行 ESB 的服务器文件系统的文件夹中.但是我该怎么做呢?如果我使用 Base64 对像Hello World"这样的简单文本进行编码,我可以使用 Script Mediator 和 Javascript 对其进行解码,但是如何将文件写入文件系统?我必须自己编写 Mediator 还是有其他我不知道的解决方案?
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?
如果你能帮助我会很好:)我正在为我的学士论文使用 WSO2 ESB.所以我还不是专业人士:)
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 :)
谢谢
推荐答案
你有几个选择,
如果文件很小,遍历
<attachments>
并针对每个附件,使用脚本中介解码并写入具有如下语法的文件,
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>
如果文件很大,那么编写自己的类调解器会更有效
If the files are large then it's more efficient to write your own class mediator
这篇关于WSO2 ESB - 从 base64 写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!