Mule flow 在文件开头添加奇怪的字符
Mule flow adding weird characters to beginning of file
我只是在移动文件,但出于某种原因,他们将奇怪的字符附加到文件的前面。
之前:
(使用 UTF-8 编码)
testCol1,testCol2,testCol3
之后:(使用 ANSI 编码)
¬í ur [B¬óøTà xp žÌtestCol1,testCol2,testCol3
我尝试过的事情:
明确将编码设置为 utf-8。
将编码明确设置为 ANSI。
使用编码设置为 utf-8 的对象到字节数组。
使用编码设置为 utf-8 的对象到字符串。
这是我的流程和相关连接器:
<sftp:connector name="Sftp" maxConnectionPoolSize="3" doc:name="SFTP"/>
<file:connector name="FileConnector" autoDelete="true" streaming="false" validateConnections="true" doc:name="FileConnector"/>
<flow name="SftpOutBound" initialState="stopped">
<file:inbound-endpoint
path="${ftp.base}/${id}/export"
pollingFrequency="${polling.frequency.millis}"
responseTimeout="${standard.response.timeout.millis}"
fileAge="${standard.fileage.delay.millis}"
connector-ref="deletingFileConnector"
doc:name="OutBound">
<file:filename-wildcard-filter pattern="${out.filter}" />
</file:inbound-endpoint>
<object-to-byte-array-transformer doc:name="Object to Byte Array" />
<all doc:name="all">
<file:outbound-endpoint
path="${archive.out}/${id}"
outputPattern="#[header:INBOUND:originalFileName]_#[function:datestamp:${standard.date.format}]_#[function:systime]"
responseTimeout="${standard.response.timeout.millis}"
connector-ref="deletingFileConnector"
doc:name="Archive" />
<logger
level="WARN"
message="Uploaded file from ${ftp.base}/${id}/export/#[header:INBOUND:originalFileName]"
doc:name="Logger"/>
<sftp:outbound-endpoint
connector-ref="Sftp"
host="${host}"
port="${port}"
path="${in.path}"
user="${user}"
identityFile="${configFullPath}/${identity.file}"
passphrase="${passphrase}"
responseTimeout="${standard.response.timeout.millis}"
keepFileOnError="true"
duplicateHandling="overwrite"
exchange-pattern="one-way"
outputPattern="#[header:INBOUND:originalFileName]"
doc:name="SFTP"/>
</all>
</flow>
感谢您的帮助!
file:inbound-endpoint 的负载结果是 InputStream 类型。为什么不保持原样 (byte[]) 由文件和 sftp 出站端点保存?
如果一定要转成字符串,那么我建议你看完后用<byte-array-to-string-transformer />
代替<object-to-byte-array-transformer />
所以这似乎是 Mule 3.5.0 的问题,当我升级到 3.6.1 时问题就消失了。仍然不确定是什么原因造成的,但是版本更改解决了它。
我只是在移动文件,但出于某种原因,他们将奇怪的字符附加到文件的前面。 之前:
(使用 UTF-8 编码)
testCol1,testCol2,testCol3
之后:(使用 ANSI 编码)
¬í ur [B¬óøTà xp žÌtestCol1,testCol2,testCol3
我尝试过的事情:
明确将编码设置为 utf-8。
将编码明确设置为 ANSI。
使用编码设置为 utf-8 的对象到字节数组。
使用编码设置为 utf-8 的对象到字符串。
这是我的流程和相关连接器:
<sftp:connector name="Sftp" maxConnectionPoolSize="3" doc:name="SFTP"/>
<file:connector name="FileConnector" autoDelete="true" streaming="false" validateConnections="true" doc:name="FileConnector"/>
<flow name="SftpOutBound" initialState="stopped">
<file:inbound-endpoint
path="${ftp.base}/${id}/export"
pollingFrequency="${polling.frequency.millis}"
responseTimeout="${standard.response.timeout.millis}"
fileAge="${standard.fileage.delay.millis}"
connector-ref="deletingFileConnector"
doc:name="OutBound">
<file:filename-wildcard-filter pattern="${out.filter}" />
</file:inbound-endpoint>
<object-to-byte-array-transformer doc:name="Object to Byte Array" />
<all doc:name="all">
<file:outbound-endpoint
path="${archive.out}/${id}"
outputPattern="#[header:INBOUND:originalFileName]_#[function:datestamp:${standard.date.format}]_#[function:systime]"
responseTimeout="${standard.response.timeout.millis}"
connector-ref="deletingFileConnector"
doc:name="Archive" />
<logger
level="WARN"
message="Uploaded file from ${ftp.base}/${id}/export/#[header:INBOUND:originalFileName]"
doc:name="Logger"/>
<sftp:outbound-endpoint
connector-ref="Sftp"
host="${host}"
port="${port}"
path="${in.path}"
user="${user}"
identityFile="${configFullPath}/${identity.file}"
passphrase="${passphrase}"
responseTimeout="${standard.response.timeout.millis}"
keepFileOnError="true"
duplicateHandling="overwrite"
exchange-pattern="one-way"
outputPattern="#[header:INBOUND:originalFileName]"
doc:name="SFTP"/>
</all>
</flow>
感谢您的帮助!
file:inbound-endpoint 的负载结果是 InputStream 类型。为什么不保持原样 (byte[]) 由文件和 sftp 出站端点保存?
如果一定要转成字符串,那么我建议你看完后用<byte-array-to-string-transformer />
代替<object-to-byte-array-transformer />
所以这似乎是 Mule 3.5.0 的问题,当我升级到 3.6.1 时问题就消失了。仍然不确定是什么原因造成的,但是版本更改解决了它。