使用 WSO2 EI 文件连接器无法查看下载的图像

贾斯汀

我正在使用 WSO2 EI 文件连接器将图像下载到本地文件夹,图像已成功下载,但无法查看。有人请帮助我吗?

注意: Bae64 来自 API,此处未包含。base64 内容仅是正确的,因为我可以通过使用base64 到图像转换器从这个 base64 中获取准确的图像,在axis2.xml 文件中添加如下。

<messageFormatter contentType="application/octet-stream" class="org.apache.axis2.format.BinaryFormatter"/>
    <messageBuilder contentType="application/octet-stream" class="org.apache.axis2.format.BinaryBuilder"/>

代码片段:

<sequence name="DownloadImageFileSequnce" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <log level="custom">
        <property name="===DownloadImageFileSequnce" value="called=="/>
    </log>
            <property value="D:\Test\CarSalesStockImages" name="PATH"/>
            <property expression="get-property('StockNo')" name="FOLDERNAME"/>
            <property expression="get-property('eachImageName')" name="FILENAME"/>
            <property expression="get-property('image_val')" name="CONTENT"/>

    <!-- <property name="messageType" value="application/octet-stream" scope="axis2"/> -->
    <property expression="fn:concat('file://',$ctx:PATH,'/',$ctx:FOLDERNAME,'/',$ctx:FILENAME)" name="source"/>
        <log level="custom">
        <!-- <property name="===CONTENT===" expression="get-property('CONTENT')"/> -->
        <property name="===PATH===" expression="get-property('PATH')"/>
        <property name="===FOLDERNAME===" expression="get-property('FOLDERNAME')"/>
        <property name="===FILENAME===" expression="get-property('FILENAME')"/>
        <property name="===source===" expression="get-property('source')"/>
    </log>
        <fileconnector.isFileExist>
                <source>{$ctx:source}</source>
            </fileconnector.isFileExist>
            <property expression="json-eval($.fileExist)" name="exists" type="BOOLEAN"/>
            <filter xpath="$ctx:exists">
                <then>
                    <fileconnector.append>
                        <destination>{$ctx:source}</destination>
                        <inputContent>{$ctx:CONTENT}</inputContent>
                    </fileconnector.append>
                    <payloadFactory media-type="json">
                        <format>{"status":"File updated"}</format>
                        <args/>
                    </payloadFactory>
                    <log level="custom">
                    <property name="==Response==" expression="json-eval($.)"/>
                    </log>
                </then>
                <else>
                    <fileconnector.create>
                        <source>{$ctx:source}</source>
                        <inputContent>{$ctx:CONTENT}</inputContent>
                    </fileconnector.create>
                    <payloadFactory media-type="json">
                        <format>{"status":"File created"}</format>
                        <args/>
                    </payloadFactory>
                    <log level="custom">
                    <property name="==Response==" expression="json-eval($.)"/>
                    </log>
                </else>
            </filter>
</sequence>
贾斯汀

我通过使用 vfs 而不是 wso2 文件连接器找到了解决方案。

    <?xml version="1.0" encoding="UTF-8"?>
<sequence name="DownloadImageFileSequnce" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <log level="custom">
        <property name="===DownloadImageFileSequnce" value="called=="/>
    </log>
    <property name="PATH" scope="default" type="STRING" value="D:\Test\CarSalesStockImages"/>
    <property expression="get-property('StockNo')" name="FOLDERNAME" scope="default" type="STRING"/>
    <property expression="get-property('eachImageName')" name="FILENAME" scope="default" type="STRING"/>
    <property expression="get-property('image_val')" name="CONTENT" scope="default" type="STRING"/>
    <payloadFactory media-type="xml">
        <format>
            <ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:binary>
        </format>
        <args>
            <arg evaluator="xml" expression="$ctx:CONTENT"/>
        </args>
    </payloadFactory>
    <script language="js"><![CDATA[var binaryNode =       
      mc.getEnvelope().getBody().getFirstElement().getFirstOMChild();  
   binaryNode.setBinary(true);]]></script>
    <!-- <property expression="concat($ctx:PATH,'/',$ctx:FOLDERNAME,'/',$ctx:FILENAME)" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/> -->
    <property expression="concat('vfs:file:///',$ctx:PATH,'/',$ctx:FOLDERNAME,'/',$ctx:FILENAME)" name="localpath"/>
     <header name="To" expression="get-property('localpath')"/>
    <log level="custom">
        <property expression="$ctx:localpath" name="==ReplyFileName==="/>
    </log>
    <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
    <property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
    <property name="messageType" scope="axis2" type="STRING" value="application/octet-stream"/>
    <call/>
    <payloadFactory media-type="json">
        <format>
                {                
                    "status": "success",                
                    "statusMessage" : "Image downloaded"               
                }            
             </format>
        <args/>
    </payloadFactory>
    <log level="custom">
        <property expression="json-eval($.)" name="Response"/>
    </log>

</sequence>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

WSO2 EI:如何在使用 vfs 选择 csv 文件时处理 WSO2 中的瑞典字符

WSO2 EI - 使用 REST 的 DSS 查询的输入参数

wso2 ei 使用签名调用端点

NativeWorkerPool启用DEBUG日志级别WSO2 EI 6.1.1时,使用PCML连接器时出现Uncaught异常java.lang.NoSuchMethodError

将统计信息从wso2 EI发布到wso2流处理器

WSO2 EI-SalesForce连接器未连接到部分实例

WSO2 EI和WSO2 Developer-使用http基本身份验证设置ESB代理

在WSO2 ESB / WSO2 EI中,是否有解决方案可以从gmail下载附件?

群集WSO2 EI ESB和WSO2 EI MB配置文件,WKA与多播?我的假设正确吗?

在 wso2 ei 6.5.0 中从 MS Outlook 连接器获取未读电子邮件

使用 WSO2 FHIR 连接器

如何使用 wso2 ei 更新soap响应命名空间值

WSO2 EI使用Json有效负载构造XML请求

在WSO2 EI中使用基本身份验证处理程序保护API

Script Mediator Javascript 在 WSO2 EI ESB 上无法正常工作

WSO2 EI 6.2.0 ESB调试中介无法打开Synapse调试端口

WSO2 EI、Integration Studio、碳应用程序内的自定义调解器

WSO2 EI,将序列分组到文件夹中

WSO2 EI,遍历JSON数组

通过使用丰富介体在WSO2 EI中向JSON有效负载动态添加新元素

WSO2 EI / ESB:使用正则表达式实现Switch介体和Filter介体

wso2 ei服务器,禁止错误403,无法访问核心,错误:请求中缺少必需的令牌

无法使用WGET下载WSO2 DSS 3.0.1

Wso2 Ei 6.3 自签名认证错误

WSO2 EI,从属性加载验证模式

如何从WSO2 EI Studio调用外部Rest API?

带有 RabbitMQ 的 WSO2 EI - 如何拒绝消息?

WSO2 EI每个端点多个证书

在WSO2 EI中部署Ruby / Python后端服务