我和这个人有同样的问题: WSO2 ESB - writing files out of base64
然而,在该问题的答案中,没有提到如何在JavaScript中解码Base64字符串并将其附加到有效负载。这就是我感兴趣的东西。
提前致谢,
Strainy
答案 0 :(得分:0)
采用略有不同的方法。我创建了一个实用程序代理服务来重新下载文件,然后将其推入文件系统。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="utility_createFile"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="utility_createFile_IN" outSequence="utility_createFile_OUT"/>
<description/>
</proxy>
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="utility_createFile_IN" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<property expression="//createFile/download_folder"
name="uri.var.download_folder" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="//createFile/url" name="uri.var.download_url" xmlns:ns="http://org.apache.synapse/xsd"/>
<script language="js"><![CDATA[var download_url = mc.getProperty('uri.var.download_url');
download_url = decodeURIComponent(download_url);
mc.setProperty('uri.var.download_url', download_url);]]></script>
<send>
<endpoint>
<http method="GET" uri-template="{uri.var.download_url}"/>
</endpoint>
</send>
</sequence>
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="utility_createFile_IN" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<property expression="//createFile/download_folder"
name="uri.var.download_folder" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="//createFile/url" name="uri.var.download_url" xmlns:ns="http://org.apache.synapse/xsd"/>
<script language="js"><![CDATA[var download_url = mc.getProperty('uri.var.download_url');
download_url = decodeURIComponent(download_url);
mc.setProperty('uri.var.download_url', download_url);]]></script>
<send>
<endpoint>
<http method="GET" uri-template="{uri.var.download_url}"/>
</endpoint>
</send>
</sequence>