OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Uploading zip file to Camel Rest end point


Hi All,

Could somebody suggest how do I unmarshall a zip file sent to Camel 2.18.5
rest endpoint and read it into ZipInputStream?

In my route, I have tried using "*.unmarshal().zipFile()*" and sending a
request using "*multipart/form-data*" from Postman. However, when I
decorate the exchange input stream to *ZipInputStream*, it doesn't work.

On the other hand, if I use "*.unmarshal().mimeMultipart()*", converting it
to *ZipInputStream* still doesn't work (stream seems to be empty after I
decorate it), but I am able to use *MultipartEntityBuilder*:

  MultipartEntityBuilder b = MultipartEntityBuilder.create();

  b.addBinaryBody("file", exchange.getIn().getBody(InputStream.class));

  HttpEntity entity = b.build();

  ByteArrayOutputStream bos = new ByteArrayOutputStream();

  entity.writeTo(bos);

  System.out.println("BYTES:\n"+bos.toString());


Please note that the zip file could be large (can contain video files as
well) and expecting it to be sent as multipart from client side (but this
can be changed based on suggestions I receive). Also, I have gone through
several documentation and stack overflow already.


Any help will be appreciated.


Thank you,

Arpit