Thanks for pointing that out.
I changed that to this and it remaind the same
byte[] data =
exchange.getContext().getTypeConverter().convertTo(byte[].class,
dh.getInputStream());
Message newMessage = exchange.getIn();
newMessage.setHeader("org.apache.camel.file.name",
filename);
newMessage.setBody(data);
newMessage.removeAttachment("filename");
Claus Ibsen-2 wrote:
>
> Its a HEADER not a property that you can use to set the filename.
>
>
> On Fri, Feb 19, 2010 at 11:39 AM, lekkie <[email protected]> wrote:
>>
>> Hi,
>>
>> After going through this doc http://camel.apache.org/file.html, I
>> understand
>> I can set the filename by setting org.apache.camel.file.name value.
>>
>> I have a camel application that retrieves an attachment from an email and
>> drops the attachment into a folder.
>>
>> Here is my mail attachment processor (I got this same site above):
>>
>> if (attachments.size() > 0)
>> {
>> for (String name : attachments.keySet())
>> {
>> DataHandler dh = attachments.get(name);
>> // get the file name
>> String filename = dh.getName();
>> LOG.info("Filename: " + filename);
>>
>> exchange.setProperty("org.apache.camel.file.name",
>> filename);
>>
>> // get the content and convert it to byte[]
>> byte[] data =
>> exchange.getContext().getTypeConverter().convertTo(byte[].class,
>> dh.getInputStream());
>> Message newMessage = exchange.getIn();
>> newMessage.setBody(data);
>> newMessage.removeAttachment("filename");
>>
>> LOG.info("org.apache.camel.file.name: " +
>> exchange.getProperty("org.apache.camel.file.name"));
>>
>> // write the data to a file
>> // FileOutputStream out = new FileOutputStream(filename);
>> // out.write(data);
>> // out.flush();
>> // out.close();
>> }
>> }
>>
>> and here is my camrel app
>>
>> <route>
>> <from
>> uri="pop3://[email protected]&password=password&delete=true&fetchSize=5&debugMode=true"/>
>> <process ref="mailAttachmentProcessor"/>
>> <to uri="file:///d:/autopay"/>
>> </route>
>>
>> What could be wrong with this?
>> --
>> View this message in context:
>> http://old.nabble.com/Naming-your-file-with-org.apache.camel.file.name-tp27652299p27652299.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
--
View this message in context:
http://old.nabble.com/Naming-your-file-with-org.apache.camel.file.name-tp27652312p27652575.html
Sent from the Camel - Users mailing list archive at Nabble.com.