Sidebar

With an FTP source node, how do I copy the file to a local folder?

0 votes
643 views
asked Jan 20, 2020 by lewis-s-9714 (1,020 points)
We're creating messages from a file in an FTP location using a CSV-FTP source node, but the "After downloading from FTP site" option doesn't appear to allow me to move the file to a local directory. I get the error "org.apache.camel.component.file.GenericFileOperationFailedException: Cannot list directory: D:\FakePathByLewis", and I see in the reference manual that the function is intended for moving to another folder on the same FTP. How do I get a copy of the file that isn't on the FTP?

1 Answer

+1 vote

If you wanted a copy of your original file you could select the check box "Run preprocessing script on all messages received" in order to read the file and write it out to a local file.

If you just wanted a copy of each message, you can have as many destination nodes as you like. This means that you can have a destination of a file folder connected directly to your source node. That destination does not require any mappings happen first so you can have a copy of your 

answered Jan 20, 2020 by michael-h-5027 (14,350 points)
commented Jan 20, 2020 by lewis-s-9714 (1,020 points)
Thanks! I needed to cast as a Java string with a particular encoding without interfering with the messages to finish making this work, but now we're getting our file copy and still getting the messages.

var bytesTemp = new java.lang.String(bytesIn, 'UTF-8');
qie.writeFile('D:\\FakePathByLewis\\FakeFile' + qie.formatDate('yyyyMMddhhmmssSSS') + '.csv', bytesTemp, false);
bytesTemp = null;

bytesOut = bytesIn; //to be processed through the channel
...