我正在尝试使用 mule 3.6 开发一个休息层,我在其中通过 POST 方法接收文件上传。
我创建了以下流程:
<flow name="post:/campaigns/{campaignId}/files:multipart/form-data:api-config">
<logger message="#[flowVars.nameFile]" level="INFO" doc:name="Logger"/>
<foreach collection="#[message.inboundAttachments]" doc:name="Foreach">
<file:outbound-endpoint path="C:\Users\valter.gomes\Desktop\Nova pasta" outputPattern="#[message.outboundProperties]" connector-ref="File" responseTimeout="10000" doc:name="File"/>
</foreach>
</flow>
但是我无法获取上传文件的名称。我试过:#[message.outboundProperties.filename] , #[message.inboudProperties.filename] , #[header:filename]
但是堆栈跟踪是:
Message : Failed to route event via endpoint: `enter code here`DefaultOutboundEndpoint{endpointUri=file:///C:/Users/valter.gomes/Desktop/Nova%20pasta/, connector=FileConnector
{
name=File
lifecycle=start
this=7f3f15d8
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[file]
serviceOverrides=<none>
}
, name='endpoint..C.Users.valter.gomes.Desktop.Nova pasta', mep=ONE_WAY, properties={outputPattern=#[header:filename]}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: DataHandler
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Expression Evaluator "header" with expression "outbound:filename" returned null but a value was required. (org.mule.api.expression.RequiredValueException)
org.mule.expression.ExpressionUtils:235 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/RequiredValueException.html)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file:///C:/Users/valter.gomes/Desktop/Nova%20pasta/, connector=FileConnector
{
name=File
lifecycle=start
this=7f3f15d8
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[file]
serviceOverrides=<none>
}
, name='endpoint..C.Users.valter.gomes.Desktop.Nova pasta', mep=ONE_WAY, properties={outputPattern=#[header:filename]}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: DataHandler (org.mule.api.transport.DispatchException)
org.mule.transport.AbstractMessageDispatcher:117 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.expression.RequiredValueException: Expression Evaluator "header" with expression "outbound:filename" returned null but a value was required.
at org.mule.expression.ExpressionUtils.getPropertyInternal(ExpressionUtils.java:235)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:63)
at org.mule.expression.ExpressionUtils.getPropertyWithScope(ExpressionUtils.java:46)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
请问有人知道如何使用 file:outbound-endpoint 获取此文件名吗?或者还有其他方法可以做到这一点吗?
感谢您的关注,
瓦尔特·戈麦斯
我是一名优秀的程序员,十分优秀!