You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by Rustam Aliyev <ru...@code.az> on 2011/07/16 14:12:16 UTC

MIME part size

Hi,

First of all, sorry for addressing this question to the dev group, but I 
was unable to find any mime4j user groups.

I need to get MIME part size (e.g. size of attachment/BinaryBody) but 
can't figure out how to do it. At the moment I use DOM parser and then 
read through part.getBody().getInputStream() to calculate its size. 
Clearly this is not the best way.

Also, is it possible to get mime encoded size as well as original 
(decoded) size?

PS: I'm using latest 0.7 snapshot.

Regards,
Rustam.

<http://www.linkedin.com/in/aliyev>

Re: MIME part size

Posted by Norman Maurer <no...@apache.org>.
Am 18.07.2011 13:10, schrieb Oleg Kalnichevski:
> On Mon, 2011-07-18 at 10:37 +0100, Rustam Aliyev wrote:
>> Thanks Oleg.
>>
>> Would it be possible to add body part size calculation in 0.8? I haven't
>> looked into the code, but it shouldn't be too complicated since mime4j
>> reads through the parts anyway.
>>
> This might be quite difficult (or dog ugly) at the parser (core) level
> but should be fairly easy at the dom level. Feel free to raise a request
> in JIRA for this feature.
>
> Oleg

And we love patches ;)

Bye,
Norman


Re: MIME part size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2011-07-18 at 10:37 +0100, Rustam Aliyev wrote:
> Thanks Oleg.
> 
> Would it be possible to add body part size calculation in 0.8? I haven't 
> looked into the code, but it shouldn't be too complicated since mime4j 
> reads through the parts anyway.
> 

This might be quite difficult (or dog ugly) at the parser (core) level
but should be fairly easy at the dom level. Feel free to raise a request
in JIRA for this feature.

Oleg 



Re: MIME part size

Posted by Rustam Aliyev <ru...@code.az>.
Thanks Oleg.

Would it be possible to add body part size calculation in 0.8? I haven't 
looked into the code, but it shouldn't be too complicated since mime4j 
reads through the parts anyway.

--
Rustam.

On 18/07/2011 10:27, Oleg Kalnichevski wrote:
> On Mon, 2011-07-18 at 00:40 +0100, Rustam Aliyev wrote:
>> Hi Norman,
>>
>> BodyDescriptor only has getContentLength() which returns "Content
>> length, if known, or -1, to indicate the absence of a content-length
>> header".
>>
>> Taking into account that most of attachment don't have content-length,
>> this won't be very helpful.   ... or am I missing somehitng?
>>
>>
>> Thanks,
>> Rustam.
>>
> Rustam
>
> Reading through the content of a body part is the only reliable way of
> finding its length.
>
> Oleg
>
>
>

Re: MIME part size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2011-07-18 at 00:40 +0100, Rustam Aliyev wrote:
> Hi Norman,
> 
> BodyDescriptor only has getContentLength() which returns "Content 
> length, if known, or -1, to indicate the absence of a content-length 
> header".
> 
> Taking into account that most of attachment don't have content-length, 
> this won't be very helpful.   ... or am I missing somehitng?
> 
> 
> Thanks,
> Rustam.
> 

Rustam

Reading through the content of a body part is the only reliable way of
finding its length. 

Oleg



Re: MIME part size

Posted by Rustam Aliyev <ru...@code.az>.
Hi Norman,

BodyDescriptor only has getContentLength() which returns "Content 
length, if known, or -1, to indicate the absence of a content-length 
header".

Taking into account that most of attachment don't have content-length, 
this won't be very helpful.   ... or am I missing somehitng?


Thanks,
Rustam.

On 17/07/2011 19:23, Norman Maurer wrote:
> Hi there,
>
> this should be possible with the BodyDescriptor.
>
> http://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/descriptor/BodyDescriptor.html
>
> Bye,
> Norman
>
>
> 2011/7/16 Rustam Aliyev<ru...@code.az>:
>> Hi,
>>
>> First of all, sorry for addressing this question to the dev group, but I was
>> unable to find any mime4j user groups.
>>
>> I need to get MIME part size (e.g. size of attachment/BinaryBody) but can't
>> figure out how to do it. At the moment I use DOM parser and then read
>> through part.getBody().getInputStream() to calculate its size. Clearly this
>> is not the best way.
>>
>> Also, is it possible to get mime encoded size as well as original (decoded)
>> size?
>>
>> PS: I'm using latest 0.7 snapshot.
>>
>> Regards,
>> Rustam.
>>
>> <http://www.linkedin.com/in/aliyev>
>>

Re: MIME part size

Posted by Norman Maurer <no...@googlemail.com>.
Hi there,

this should be possible with the BodyDescriptor.

http://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/descriptor/BodyDescriptor.html

Bye,
Norman


2011/7/16 Rustam Aliyev <ru...@code.az>:
> Hi,
>
> First of all, sorry for addressing this question to the dev group, but I was
> unable to find any mime4j user groups.
>
> I need to get MIME part size (e.g. size of attachment/BinaryBody) but can't
> figure out how to do it. At the moment I use DOM parser and then read
> through part.getBody().getInputStream() to calculate its size. Clearly this
> is not the best way.
>
> Also, is it possible to get mime encoded size as well as original (decoded)
> size?
>
> PS: I'm using latest 0.7 snapshot.
>
> Regards,
> Rustam.
>
> <http://www.linkedin.com/in/aliyev>
>