我有一个端点,该端点接受包含文件附件的multipart / form POST。我使用
获取文件名#[message.inboundAttachments.myfile.dataSource.part.fileName]
这可以正常工作,但是如果文件名包含“£”符号,则它似乎是经过双重编码的,因此,例如£10.txt
变为£10.txt
。我该如何预防?
我正在使用Mule 3.8.0。
RAML:
#%RAML 0.8
title: pound-encoding-demo
/files:
post:
description: post a file
body:
multipart/form-data:
formParameters:
myfile:
description: a file to be uploaded
required: true
type: file
应用程序:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<flow name="api-main">
<http:listener config-ref="HTTP_Listener_Configuration" path="/pound-encoding-demo/files" doc:name="HTTP" />
<set-payload value="#[message.inboundAttachments.myfile.dataSource.part.fileName]" doc:name="Set Payload" />
</flow>
</mule>
示例调用(假设当前目录中存在名为test-£10.txt
的文件):
curl -X POST http://localhost:8081/pound-encoding-demo/files -H 'content-type: multipart/form-data; boundary=----XYZZY12345' -F 'myfile=@test-£10.txt'
谢谢。