Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 使用WSO2 EI文件连接器无法查看下载的图像_Image_File_Wso2ei - Fatal编程技术网

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

Image 使用WSO2 EI文件连接器无法查看下载的图像,image,file,wso2ei,Image,File,Wso2ei,我正在使用WSO2 EI文件连接器将图像下载到本地文件夹,图像已成功下载,但无法查看。谁能帮帮我 正在从数据库获取图像URL(例如) 从imageURL获取base64内容 然后使用文件连接器将这些内容插入本地文件夹 注意:Bae64来自API,此处不包括该API。base64内容仅是正确的,因为我可以使用 在axis2.xml文件中添加了以下内容 <messageFormatter contentType="application/octet-stream" class="org.a

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

  • 正在从数据库获取图像URL(例如)
  • 从imageURL获取base64内容
  • 然后使用文件连接器将这些内容插入本地文件夹
注意:Bae64来自API,此处不包括该API。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>

{$ctx:source}
{$ctx:source}
{$ctx:CONTENT}
{“状态”:“文件已更新”}
{$ctx:source}
{$ctx:CONTENT}
{“状态”:“文件已创建”}

我找到了使用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>

$1
{                
“状态”:“成功”,
“statusMessage”:“已下载图像”
}            

我找到了使用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>

$1
{                
“状态”:“成功”,
“statusMessage”:“已下载图像”
}