首页 > 解决方案 > wso2 EI中的多部分

问题描述

我有一个要求,我应该将 gzip 文件上传到 wso2 EI 服务器。

我在系统中有一个文件(gzip)(运行java)。我需要将此文件发送到托管在 wso2ei 中的 API,该 API 将存储此文件。由于文件可能很大,我需要 API 来支持多部分文件上传。我想在 wso2 EI 中编写一个支持多部分的 API,并将获取此文件并存储在 EI 服务器本身的某个位置。我不想使用 VFS。

下面是我尝试但不工作的代码。它创建了一个损坏的 zip 文件。如果我要提供一个巨大的文件,那么我也会出现内存不足错误。虽然在使用多部分时,我没想到内存不足错误(无论文件大小)。

注意:我尝试不解码身体。应用程序/zip 内容类型也是如此。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/upload" name="MultiPartAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" >
        <inSequence>
            <property expression="json-eval($)" name="inputPayLoad" scope="default" type="STRING"/>
            <property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
            <property name="ContentType" scope="axis2" type="STRING" value="multipart/form-data"/>
            <property expression="//mediate/data/text()" name="payload" scope="default" type="STRING"/>
            <property expression="//mediate/data/@filename" name="fileName" scope="default" type="STRING"/>
            <log level="custom">
                <property name="===========" value="================="/>
                <property expression="$ctx:fileName" name="fileName"/>
            </log>
            <property expression="base64Decode(get-property('payload'))" name="DecodeBody" scope="default" type="STRING"/>
            <property description="File full path" expression="fn:concat('\home\files\gzip\',$ctx:fileName)" name="fileFullPath" scope="default" type="STRING"/>
            <property name="messageType" scope="axis2" type="STRING" value="application/octet-stream"/>
            <property name="ContentType" scope="axis2" type="STRING" value="application/octet-stream"/>
            <fileconnector.create>
                <source>{$ctx:fileFullPath}</source>
                <inputContent>{$ctx:DecodeBody}</inputContent>
            </fileconnector.create>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

BR//维平尼尔瓦尔

标签: wso2multipartform-datawso2ei

解决方案



推荐阅读