wso2 - 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//维平尼尔瓦尔
解决方案
推荐阅读
- python - Docker Compose Nginx 内部服务器错误
- python - 删除熊猫数据框中的所有特殊字符
- angular - 如何避免带有逻辑和副作用的嵌套订阅
- html - 无法在 asp.net core 中正确显示背景图像
- batch-file - 使用 windows CMD 创建一个文件,并用重复的行但不同的值填充它
- excel - 在 Excel 中使用 LAMBDA 仅将第一个字母大写
- google-apps-script - 无法读取 null 的属性“getSheetByName”
- .net-core - 使用 IServiceCollection 注册组件
- html - 如何禁用特定元素的下拉列表
- java - 根据选定的 Maven 配置文件设置应用程序配置