First, sorry for my bad english.
The problem is I can not upload a file (.xls) file on a local FTP server.
This is the Exception :
[org.apache.camel.component.file.GenericFileOperationFailedException - Error writing file GAS_EAV_EMV.xls]
This is my route :
<route id="sendFtp">
<from uri="direct:sendFtp"/>
<setHeader headerName="CamelFileName">
<simple>GAS_EAV_EMV.xls</simple>
</setHeader>
<process ref="egssisFtpProcessor"/>
<to uri="ftp://foo@127.0.0.1:21/?password=pwd"/>
</route>
Here my Processor to attach the file :
public class EgssisFtpProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
String filename = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
exchange.getIn().addAttachment(filename, new DataHandler(new FileDataSource(filename)));
}
}
The exchange object has the attachment at the end of the processor.
It works with the SMTP protocol but not with FTP.
Any idea ?
Server log :
[14:29:29] - [78] Connecté à 127.0.0.1. Collecte du Nom d'utilisateur.
[14:29:29] - [78] Usager FOO Connecté IP: 127.0.0.1
[14:29:29] - [78] FOO : Répertoire en Cours: C:\tmp\
[14:29:29] - [78] Client 127.0.0.1 Déconnecté (00:00:00 Min)
Attachements is not used. Instead just set the message body to a java.io.File for the file you want to upload.
And since you use XML you may want to do this without any java code. You can use the message translator EIP to convert the message body to a java.io.File with the header as the file name.