james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Burrell Donkin" <robertburrelldon...@gmail.com>
Subject Re: [mime4j] OutputStream support for StorageProvider?
Date Wed, 03 Dec 2008 20:23:29 GMT
On Wed, Dec 3, 2008 at 7:59 PM, Markus Wiederkehr
<markus.wiederkehr@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


Mime
View raw message