I have a requirement where i am supposed to upload a gzip file to wso2 EI server.
I have a file(gzip) in a system(running java). I need to send this file to a API hosted in wso2ei, which will store this. Since file can be HUGE, I need the API to support multi part file upload. 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. I do not want to use VFS.
Below is the code that i tried but not working. Its creating a corrupted zip file. If i am giving a huge file, then i am getting out of memory error too. Though while using multipart, i was not expecting out of memory error(irrespective the size of file).
Note: I tried without decoding the body. With application/zip content type as well.
<?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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.