You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Laurentiu Trica <la...@finalfolder.biz> on 2011/04/14 16:08:36 UTC
Camel Mail with attachment problem
Hello,
I have a problem using Camel Mail. I can get emails with attachments without
any problem.
But when I send an email with attachment, the attachment gets truncated and
I see only the last 3KB of it.
I have to add that I construct my attachment from converting the route
content(String) into attachment, if this makes any difference, but I tested
the "conversion" and nothing disappears in there because using Servicemix
Mail does the trick...
Has anyone any idea about this?
--
Laurentiu Trica
Software Developer Mobile: (+40) 722 329318
S.C MoreDevs S.R.L. Email: laurentiu.trica@finalfolder.biz
This message can contain privileged or confidential information and it is
intended only for addressee. Any unauthorized disclosure is strictly
prohibited.
Re: Camel Mail with attachment problem
Posted by Laurentiu Trica <la...@finalfolder.biz>.
Hello,
We solved the problem. We don't use StreamDataSource anymore, we use
ByteArrayDataSource.
It seems to be a problem while using the StreamDataSource, although the
stream was ok, because we wiretapped it before and the resulted file was
good.
Thanks for helping, anyway.
Laurentiu
On Fri, Apr 22, 2011 at 5:01 PM, Willem Jiang <wi...@gmail.com>wrote:
> The code looks good to me.
> Can you check if the stream is right?
> Can you dump the stream to see if it is truncated?
>
> Willem
>
>
> On 4/22/11 9:10 PM, Laurentiu Trica wrote:
>
>> Hello,
>>
>> I use this code:
>>
>> public class ContentToAttachment extends AbstractTransparentProcessor {
>>
>> private String contentType = "application/octet-stream";
>>
>> public void process(Exchange exchange) throws Exception {
>> Message msg = transferData(exchange);
>>
>> InputStream stream = (InputStream) msg.getBody();
>>
>> String attachmentId = (String)
>> msg.getHeader(UtilConstants.CAMEL_FILENAME_KEY);
>> if (attachmentId == null){
>> attachmentId = UtilConstants.CAMEL_FILENAME_KEY;
>> }
>>
>> DataHandler handler = new DataHandler(new StreamDataSource(stream,
>> contentType, attachmentId));
>>
>> msg.addAttachment(attachmentId, handler);
>> msg.setBody("");
>> }
>> }
>>
>> Shouldn't this work ok with Camel?
>> Are there some default length limits for attachments?
>>
>>
>> On Fri, Apr 15, 2011 at 5:06 AM, Willem Jiang<willem.jiang@gmail.com
>> >wrote:
>>
>> Hi,
>>>
>>> How do you setup the attachment?
>>> I don't think converting the message body into attachment will lost the
>>> date.
>>>
>>>
>>>
>>> On 4/14/11 10:08 PM, Laurentiu Trica wrote:
>>>
>>> Hello,
>>>>
>>>> I have a problem using Camel Mail. I can get emails with attachments
>>>> without
>>>> any problem.
>>>> But when I send an email with attachment, the attachment gets truncated
>>>> and
>>>> I see only the last 3KB of it.
>>>> I have to add that I construct my attachment from converting the route
>>>> content(String) into attachment, if this makes any difference, but I
>>>> tested
>>>> the "conversion" and nothing disappears in there because using
>>>> Servicemix
>>>> Mail does the trick...
>>>>
>>>> Has anyone any idea about this?
>>>>
>>>>
>>>>
>>> --
>>> Willem
>>> ----------------------------------
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog: http://willemjiang.blogspot.com (English)
>>> http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>>
>>> Connect at CamelOne May 24-26
>>> The Open Source Integration Conference
>>> http://camelone.com
>>>
>>>
>>
>>
>>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>
> Connect at CamelOne May 24-26
> The Open Source Integration Conference
> http://camelone.com
>
--
Laurentiu Trica
Software Developer Mobile: (+40) 722 329318
S.C MoreDevs S.R.L. Email: laurentiu.trica@finalfolder.biz
This message can contain privileged or confidential information and it is
intended only for addressee. Any unauthorized disclosure is strictly
prohibited.
Re: Camel Mail with attachment problem
Posted by Willem Jiang <wi...@gmail.com>.
The code looks good to me.
Can you check if the stream is right?
Can you dump the stream to see if it is truncated?
Willem
On 4/22/11 9:10 PM, Laurentiu Trica wrote:
> Hello,
>
> I use this code:
>
> public class ContentToAttachment extends AbstractTransparentProcessor {
>
> private String contentType = "application/octet-stream";
>
> public void process(Exchange exchange) throws Exception {
> Message msg = transferData(exchange);
>
> InputStream stream = (InputStream) msg.getBody();
>
> String attachmentId = (String)
> msg.getHeader(UtilConstants.CAMEL_FILENAME_KEY);
> if (attachmentId == null){
> attachmentId = UtilConstants.CAMEL_FILENAME_KEY;
> }
>
> DataHandler handler = new DataHandler(new StreamDataSource(stream,
> contentType, attachmentId));
>
> msg.addAttachment(attachmentId, handler);
> msg.setBody("");
> }
> }
>
> Shouldn't this work ok with Camel?
> Are there some default length limits for attachments?
>
>
> On Fri, Apr 15, 2011 at 5:06 AM, Willem Jiang<wi...@gmail.com>wrote:
>
>> Hi,
>>
>> How do you setup the attachment?
>> I don't think converting the message body into attachment will lost the
>> date.
>>
>>
>>
>> On 4/14/11 10:08 PM, Laurentiu Trica wrote:
>>
>>> Hello,
>>>
>>> I have a problem using Camel Mail. I can get emails with attachments
>>> without
>>> any problem.
>>> But when I send an email with attachment, the attachment gets truncated
>>> and
>>> I see only the last 3KB of it.
>>> I have to add that I construct my attachment from converting the route
>>> content(String) into attachment, if this makes any difference, but I
>>> tested
>>> the "conversion" and nothing disappears in there because using Servicemix
>>> Mail does the trick...
>>>
>>> Has anyone any idea about this?
>>>
>>>
>>
>> --
>> Willem
>> ----------------------------------
>> FuseSource
>> Web: http://www.fusesource.com
>> Blog: http://willemjiang.blogspot.com (English)
>> http://jnn.javaeye.com (Chinese)
>> Twitter: willemjiang
>>
>> Connect at CamelOne May 24-26
>> The Open Source Integration Conference
>> http://camelone.com
>>
>
>
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com
Re: Camel Mail with attachment problem
Posted by Laurentiu Trica <la...@finalfolder.biz>.
Hello,
I use this code:
public class ContentToAttachment extends AbstractTransparentProcessor {
private String contentType = "application/octet-stream";
public void process(Exchange exchange) throws Exception {
Message msg = transferData(exchange);
InputStream stream = (InputStream) msg.getBody();
String attachmentId = (String)
msg.getHeader(UtilConstants.CAMEL_FILENAME_KEY);
if (attachmentId == null){
attachmentId = UtilConstants.CAMEL_FILENAME_KEY;
}
DataHandler handler = new DataHandler(new StreamDataSource(stream,
contentType, attachmentId));
msg.addAttachment(attachmentId, handler);
msg.setBody("");
}
}
Shouldn't this work ok with Camel?
Are there some default length limits for attachments?
On Fri, Apr 15, 2011 at 5:06 AM, Willem Jiang <wi...@gmail.com>wrote:
> Hi,
>
> How do you setup the attachment?
> I don't think converting the message body into attachment will lost the
> date.
>
>
>
> On 4/14/11 10:08 PM, Laurentiu Trica wrote:
>
>> Hello,
>>
>> I have a problem using Camel Mail. I can get emails with attachments
>> without
>> any problem.
>> But when I send an email with attachment, the attachment gets truncated
>> and
>> I see only the last 3KB of it.
>> I have to add that I construct my attachment from converting the route
>> content(String) into attachment, if this makes any difference, but I
>> tested
>> the "conversion" and nothing disappears in there because using Servicemix
>> Mail does the trick...
>>
>> Has anyone any idea about this?
>>
>>
>
> --
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
>
> Connect at CamelOne May 24-26
> The Open Source Integration Conference
> http://camelone.com
>
--
Laurentiu Trica
Software Developer Mobile: (+40) 722 329318
S.C MoreDevs S.R.L. Email: laurentiu.trica@finalfolder.biz
This message can contain privileged or confidential information and it is
intended only for addressee. Any unauthorized disclosure is strictly
prohibited.
Re: Camel Mail with attachment problem
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
How do you setup the attachment?
I don't think converting the message body into attachment will lost the
date.
On 4/14/11 10:08 PM, Laurentiu Trica wrote:
> Hello,
>
> I have a problem using Camel Mail. I can get emails with attachments without
> any problem.
> But when I send an email with attachment, the attachment gets truncated and
> I see only the last 3KB of it.
> I have to add that I construct my attachment from converting the route
> content(String) into attachment, if this makes any difference, but I tested
> the "conversion" and nothing disappears in there because using Servicemix
> Mail does the trick...
>
> Has anyone any idea about this?
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com