wso2 EI 中的多部分
Multipart in wso2 EI
我有一个要求,我应该将 gzip 文件上传到 wso2 EI 服务器。
我在系统中有一个文件(gzip)(运行 java)。我需要将此文件发送到 wso2ei 中托管的 API,它将存储此文件。由于文件可能很大,我需要 API 来支持多部分文件上传。我想在 wso2 EI 中写一个 API ,它将支持多部分并将这个文件存储在 EI 服务器本身的某个位置。
我不想使用 VFS。
下面是我试过但没有用的代码。它创建了一个损坏的 zip 文件。如果我给出一个巨大的文件,那么我也会出现内存不足错误。尽管在使用 multipart 时,我没有预料到内存不足错误(无论文件大小如何)。
注意:我试过不解码正文。 application/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//
维宾尼尔瓦尔
我有一个要求,我应该将 gzip 文件上传到 wso2 EI 服务器。
我在系统中有一个文件(gzip)(运行 java)。我需要将此文件发送到 wso2ei 中托管的 API,它将存储此文件。由于文件可能很大,我需要 API 来支持多部分文件上传。我想在 wso2 EI 中写一个 API ,它将支持多部分并将这个文件存储在 EI 服务器本身的某个位置。 我不想使用 VFS。
下面是我试过但没有用的代码。它创建了一个损坏的 zip 文件。如果我给出一个巨大的文件,那么我也会出现内存不足错误。尽管在使用 multipart 时,我没有预料到内存不足错误(无论文件大小如何)。
注意:我试过不解码正文。 application/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// 维宾尼尔瓦尔