WSO2 ESB:如何使用 VFS 从 Base64 写入文件? [英] WSO2 ESB: How to write a file from Base64 with VFS?

查看:25
本文介绍了WSO2 ESB:如何使用 VFS 从 Base64 写入文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和这个人有几乎相同的问题:WSO2 ESB - 从 base64 写入文件

I have pretty much the same issue as this person: WSO2 ESB - writing files out of base64

但是,在对该问题的回答中没有提到如何在 JavaScript 中解码 Base64 字符串并将其附加到有效负载.这就是我感兴趣的.

However, in the answer to that question there was no mention of how to decode the Base64 string in JavaScript and attach it to the payload. That's what I'm interested in.

提前致谢,

紧张

推荐答案

采用了稍微不同的方法.我创建了一个实用程序代理服务来重新下载文件,然后将其推送到文件系统中.

Went with a slightly different approach. I created a utility proxy service to re-download the file and then push it into the file system.

<?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>

utility_createFile_IN 序列

<?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>

utility_createFile_OUT 序列

<?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>

这篇关于WSO2 ESB:如何使用 VFS 从 Base64 写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆