Original issue 297 created by soi-toolkit on 2012-09-11T13:55:31.000Z:
This mainly applies for integrations that uses SFTP on inbound endpoints. It could apply to other integrations as well.
Using MiscUtil.readFileAsString requires two unnecessary conversions that involves encoding (file -> convert -> String -> convert -> file). If the content of the file is read into a bytearray instead there is no need for any conversion that takes encoding into account.
Currently there is a bug in mule sftp connector that has to be worked around due to the encoding dependent conversion:
Original issue 297 created by soi-toolkit on 2012-09-11T13:55:31.000Z:
This mainly applies for integrations that uses SFTP on inbound endpoints. It could apply to other integrations as well.
Using MiscUtil.readFileAsString requires two unnecessary conversions that involves encoding (file -> convert -> String -> convert -> file). If the content of the file is read into a bytearray instead there is no need for any conversion that takes encoding into account.
Currently there is a bug in mule sftp connector that has to be worked around due to the encoding dependent conversion:
http://www.mulesoft.org/jira/browse/MULE-6055
So use:
byte [] input = IOUtils.toByteArray(new FileInputStream(inputFile));
instead of
String input = MiscUtil.readFileAsString(inputFile);
Where IOUtils is from commons-io (org.apache.commons.io.IOUtils)
I think that both methods readFileAsString can be dropped since they are available in IOUtils.