Thank you so much Stephan for your response. I was thinking I was doing 
something wrong on these forums or email chats - thank you. You are completely 
right, I have that in place didn't share it yet.  However, I believe I have 
solved this.  It was type conversion - go figure, I was changing the type to 
String object instead of using the serialized entry byte stream.  After this 
change - I'm golden. 

Thank you again, 
Have a great day!
Gary

-----Original Message-----
From: Siano, Stephan [mailto:stephan.si...@sap.com] 
Sent: Wednesday, November 02, 2016 2:36 AM
To: users@camel.apache.org
Subject: EXT: RE: zipfile question - thank you

Hi,

how do you retreive the message from the mail server? On the server an email 
with a zip file attachment is actually a MIME-Multipart. One of the parts 
within that is the (usually base64 encoded) zip file. If you just read the 
message with some form(pop3:xxx) thing, and try to unmarshal that as a zip 
file, this will of course fail (because you are feeding the message body, not 
the attachment into it).

If you want to process the attachment, you will first need to add some 
processor that fetches the attachment from the message and puts the InputStream 
of the payload as the main message body.

Best regards
Stephan

-----Original Message-----
From: Mills, Gary (GE Digital) [mailto:gary.l.mi...@ge.com] 
Sent: Dienstag, 1. November 2016 19:41
To: d...@camel.apache.org; users@camel.apache.org
Subject: RE: zipfile question - thank you

DefaultErrorHandler              | 198 - org.apache.camel.camel-core - 
2.15.1.redhat-620133 | Failed delivery for (MessageId: 
ID-alphprdfuse2i-43262-1478008924653-2-36907 on ExchangeId: 
ID-alphprdfuse2i-43262-1478008924653-2-36908). Exhausted after delivery 
attempt: 1 caught: org.apache.camel.InvalidPayloadException: No body available 
of type: java.lang.String but has value: 
org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper@bcbe474 of type: 
org.apache.camel.dataformat.zipfile.ZipInputStreamWrapper on: Message: [Body is 
instance of java.io.InputStream]. Caused by: Error during type conversion from 
type: java.lang.String to the required type: java.lang.String with value [Body 
is instance of java.io.InputStream] due java.util.zip.ZipException: invalid 
code lengths set. Exchange[Message: [Body is instance of java.io.InputStream]]. 
Caused by: [org.apache.camel.TypeConversionException - Error during type 
conversion from type: java.lang.String to the required type: java.lang.String 
with value [Body is instance of java.io.InputStream] due 
java.util.zip.ZipException: invalid code lengths set]

I am very confused.  If I take that zip file and simply drop it in the 
fileEntranceEndpoint everything works fine. If I send it through email it 
doesn't work. The only thing I've noticed is that the zip file appears to be 
corrupted after extracting the attachment and the above is what error is thrown.

Thank you

From: Mills, Gary (GE Digital)
Sent: Tuesday, November 01, 2016 11:52 AM
To: Mills, Gary (GE Digital) <gary.l.mi...@ge.com>
Subject: RE: zipfile question - thank you

Update:

When I send an email to the endpoint email address, with an zip file 
attachment, and I open the zip file attachment directly from email endpoint 
mailbox, the zip file attachment opens ok.  It appears to be related to the 
extraction of the attachment in Camel ?

?????



From: Mills, Gary (GE Digital)
Sent: Tuesday, November 01, 2016 10:34 AM
To: 'users-i...@camel.apache.org' 
<users-i...@camel.apache.org<mailto:users-i...@camel.apache.org>>
Subject: RE: zipfile question - thank you

Here is the code used to unmarshall the zip file

       public void configure() throws Exception {

              ZipFileDataFormat zipFile = new ZipFileDataFormat();
              zipFile.setUsingIterator(true);

              
from(fileEntranceEndpoint).id("cfi.zipfile.endpointListenerRoute").log("Message 
received zip file: ${file:name}")
              
.unmarshal(zipFile).split(body(Iterator.class)).streaming().convertBodyTo(String.class)
              .log("file names from ZipFile: ${file:name}").to("file://" + 
outDirectory);
       }



From: Mills, Gary (GE Digital)
Sent: Tuesday, November 01, 2016 10:58 AM
To: 'd...@camel.apache.org' 
<d...@camel.apache.org<mailto:d...@camel.apache.org>>
Subject: zipfile question - thank you

Camel users, ( thank you )
My project is to receive a zip compressed and encrypted file attachment from a 
customer, naturally, decompress and decrypt the attachment via email transfer.

I am only focusing on the zip portion now because over email I can't get it to 
work.  Seems that the compression size changes when sent over email.

It seems my logic works, if I take the zip file and simply drop it in the route 
from my Jboss environment it works. I can zip, unzip, the file from command 
line and the camel route. However, if I send the file as an attachment over 
email, the file size changes, and of course it does not work and throws the 
error...
org.apache.camel.RuntimeCamelException: java.util.zip.ZipException: invalid 
code lengths set

which suggests the zip file attachment has been altered during its transfer 
over email. The original file size is 9044 Bytes, after email xfr becomes, 
15580 Bytes.  If I try opening it from the OS with unzip, gunzip, it shows:

[root@alphprdfuse2i latest]# unzip 
ge-ip/core/tobeprocessed/archive/cfindustries.zip.ge
Archive:  ge-ip/core/tobeprocessed/archive/cfindustries.zip.ge
caution:  zipfile comment truncated
error [ge-ip/core/tobeprocessed/archive/cfindustries.zip.ge]:  missing 
3282862893 bytes in zipfile
  (attempting to process anyway)
error [ge-ip/core/tobeprocessed/archive/cfindustries.zip.ge]:  attempt to seek 
before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)

I've tried changing the file extension to JPEG, PNG, ge, etc... with no success.

Does anyone know what I can do to get around this???

Thank you !!

Gary Mills

Reply via email to