camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller <christian.muel...@gmail.com>
Subject Re: zip file best practices
Date Mon, 28 May 2012 15:55:30 GMT
What do you think about the following proposal:

1) Add a type converter which supports a conversion from InputStream ->
ZipFile and from InputStream -> ZipInputStream
2) Implement a splitter which extract the (multiple) ZipEntry, add some
header to each of them (name of the entry, number of entries, size, ...)
and put them into its own exchange.

For the other way (create a zip archive which contain multiple entries),
you could provide an Aggregator (AggregationStrategy) which work with
ZipEntries...

My 0.02$,
Christian

On Fri, May 25, 2012 at 1:29 PM, Tyler Durvik <phangbyte@gmail.com> wrote:

> I am working on a solution for this that I can contribute to Camel.  I
> have the files being unzipped in a processor.  The processor then sets
> a header value which is a comma-separated string listing the files.
> The problem I see is that I want the splitter to generate a new Camel
> Message object for each file in zip file.  Then in each Message object
> I set a filename header for each the file that message represents.
> The problem is that the splitter generates 2 messages, each with the
> same file header value.  So here is my flow:
>
> Zip File
>
> |
>
> Unzip Processor - uncompress zip which is contained in body, then set
> header.  key = filenames, values=file1,file2
>
> |
>
> Splitter - based on "filenames" header,  set new key = filename
>
> |
>
> Message 1 - key = filename, value = file1
> Message 2 - key = filename, value = file1
>
>
> What I want is the header of Message 2 to contain file2.  I will write
> unit test to verify this if anyone does not understand or know how to
> help.
>
> Thank you for your help,
> Tyler
>
>
>
> On Thu, May 24, 2012 at 1:18 AM, Claus Ibsen <claus.ibsen@gmail.com>
> wrote:
> > On Wed, May 23, 2012 at 10:43 PM, Tyler Durvik <phangbyte@gmail.com>
> wrote:
> >> I am receiving data message from client and the body of the message is
> >> a zip file containing multiple files.  What is the best method to
> >> process the zip data?  I assume that I should use a StreamMessage.  Is
> >> there support for Camel to unzip the body as I receive it like
> >> marshaling or do I need to write an unzip processor or splitter.
> >>
> >> Thank you for your time,
> >> Tyler
> >
> > You would need to write code to unzip that yourself.
> >
> > The zip/gzip data formats is for compressing/decompression message
> > bodies, not zip files.
> >
> > There is a JIRA ticket to see if we can add support for zip files as
> well.
> > Contributions is as always welcome.
> >
> > For example maybe a iterator that can walk the zip file entries, which
> > you can then use with the Splitter EIP to process each file by file.
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
> > FuseSource
> > Email: cibsen@fusesource.com
> > Web: http://fusesource.com
> > Twitter: davsclaus, fusenews
> > Blog: http://davsclaus.blogspot.com/
> > Author of Camel in Action: http://www.manning.com/ibsen/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message