简体   繁体   English

wso2 EI 中的多部分

[英]Multipart in wso2 EI

I have a requirement where i am supposed to upload a gzip file to wso2 EI server.我有一个要求,我应该将 gzip 文件上传到 wso2 EI 服务器。

I have a file(gzip) in a system(running java).我在系统中有一个文件(gzip)(运行java)。 I need to send this file to a API hosted in wso2ei, which will store this.我需要将此文件发送到托管在 wso2ei 中的 API,它将存储此文件。 Since file can be HUGE, I need the API to support multi part file upload.由于文件可能很大,我需要 API 来支持多部分文件上传。 I want to write an API in wso2 EI which will support multipart and will take this file and store on some location on EI server itself.我想在 wso2 EI 中编写一个 API ,它将支持多部分,并将获取此文件并存储在 EI 服务器本身的某个位置。 I do not want to use VFS.我不想使用 VFS。

Below is the code that i tried but not working.以下是我尝试但无法正常工作的代码。 Its creating a corrupted zip file.它创建了一个损坏的 zip 文件。 If i am giving a huge file, then i am getting out of memory error too.如果我要提供一个巨大的文件,那么我也会摆脱 memory 错误。 Though while using multipart, i was not expecting out of memory error(irrespective the size of file).虽然在使用多部分时,我没想到会出现 memory 错误(无论文件大小)。

Note: I tried without decoding the body.注意:我试过不解码身体。 With application/zip content type as well.应用程序/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// Vipin Nirwal BR//维平尼尔瓦尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM