You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Markus Wiederkehr <ma...@gmail.com> on 2008/12/03 20:59:47 UTC

[mime4j] OutputStream support for StorageProvider?

Currently StorageProvider defines a method to create a Storage object
from an InputStream because an InputStream is what you get from
ContentHandler.

But many libraries provide some kind of mechanism to write a document
to an OutputStream. iText's PdfWriter would be one example. Writing an
XML document with LSSerializer/LSWriter would be another. Even Mime4j
has a writeTo() method declared in Body.

So what if I wanted to create an e-mail attachment from one of these
documents? Currently I'd have to write to a file or a
ByteArrayOutputStream and then create a Storage by reading back the
content. Clearly inefficient..

So I propose to add OutputStream support to StorageProvider. Here's
what it could look like:

    SomeDocument doc = ...;
    StorageProvider sp = DefaultStorageProvider.getInstance();
    StorageOutputStream out = sp.createStorageOutputStream();
    doc.writeTo(out);
    Storage storage = out.toStorage();

Then I would add methods to BodyFactory to create text or binary
bodies directly from a Storage object..

I could implement this on the weekend..

Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: [mime4j] OutputStream support for StorageProvider?

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Wed, Dec 3, 2008 at 7:59 PM, Markus Wiederkehr
<ma...@gmail.com> wrote:
> Currently StorageProvider defines a method to create a Storage object
> from an InputStream because an InputStream is what you get from
> ContentHandler.
>
> But many libraries provide some kind of mechanism to write a document
> to an OutputStream. iText's PdfWriter would be one example. Writing an
> XML document with LSSerializer/LSWriter would be another. Even Mime4j
> has a writeTo() method declared in Body.
>
> So what if I wanted to create an e-mail attachment from one of these
> documents? Currently I'd have to write to a file or a
> ByteArrayOutputStream and then create a Storage by reading back the
> content. Clearly inefficient..
>
> So I propose to add OutputStream support to StorageProvider. Here's
> what it could look like:
>
>    SomeDocument doc = ...;
>    StorageProvider sp = DefaultStorageProvider.getInstance();
>    StorageOutputStream out = sp.createStorageOutputStream();
>    doc.writeTo(out);
>    Storage storage = out.toStorage();
>
> Then I would add methods to BodyFactory to create text or binary
> bodies directly from a Storage object..
>
> I could implement this on the weekend..

sounds good

- robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org