You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Mark.Nelson" <ma...@gmail.com> on 2014/05/21 12:09:33 UTC

Camel-restlet zipped response

Hello,

I want to create a restlet service that compress the response and sent it to
the requester.

I tried to do this using camel, but the downloaded file is damaged.


	<bean id="zipFileDataFormat"
class="org.apache.camel.dataformat.zipfile.ZipFileDataFormat">
		<property name="usingIterator" value="true" />
	</bean>
	<camelContext xmlns="http://camel.apache.org/schema/spring">

		<route>
			<from uri="restlet:/v1/test" />
			<setBody>
				<constant>test</constant>
			</setBody>
			<marshal ref="zipFileDataFormat" />
		</route>
	</camelContext>
	
Is there any options that can help me to do that successfully?

Regards,
Marc



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-restlet-zipped-response-tp5751420.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-restlet zipped response

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah you may need to set a file representation that restlet supports,
see inside this source code for inspiration
https://github.com/apache/camel/blob/master/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java

On Wed, May 21, 2014 at 1:47 PM, Mark.Nelson <ma...@gmail.com> wrote:
> Thank you for your response, I tried to use zip-dataformat but I am getting
> the same issue, the generate file cannot be extracted or opened and it
> mentioned that it's a damaged file:
> The route that I used is:
>
>          from("restlet:/test")
>              .setHeader("Content-type",constant("application/zip") )
>              .setHeader("Pragma",constant( "public"))
>              .setHeader("Content-Disposition",constant( "attachment;
> filename=test.zip"))
>              .setBody(constant("file Content"))
>              .marshal()
>              .zip();
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-restlet-zipped-response-tp5751420p5751423.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Camel-restlet zipped response

Posted by "Mark.Nelson" <ma...@gmail.com>.
Thank you for your response, I tried to use zip-dataformat but I am getting
the same issue, the generate file cannot be extracted or opened and it
mentioned that it's a damaged file:
The route that I used is:

         from("restlet:/test")
             .setHeader("Content-type",constant("application/zip") )
             .setHeader("Pragma",constant( "public"))
             .setHeader("Content-Disposition",constant( "attachment;
filename=test.zip"))
             .setBody(constant("file Content"))
             .marshal()
             .zip();



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-restlet-zipped-response-tp5751420p5751423.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-restlet zipped response

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah there is 2 kind of zip

- zipfile = for files
- zip = for NOT files, eg just a stream of zipped data

So try out this instead
http://camel.apache.org/zip-dataformat.html

On Wed, May 21, 2014 at 12:09 PM, Mark.Nelson <ma...@gmail.com> wrote:
> Hello,
>
> I want to create a restlet service that compress the response and sent it to
> the requester.
>
> I tried to do this using camel, but the downloaded file is damaged.
>
>
>         <bean id="zipFileDataFormat"
> class="org.apache.camel.dataformat.zipfile.ZipFileDataFormat">
>                 <property name="usingIterator" value="true" />
>         </bean>
>         <camelContext xmlns="http://camel.apache.org/schema/spring">
>
>                 <route>
>                         <from uri="restlet:/v1/test" />
>                         <setBody>
>                                 <constant>test</constant>
>                         </setBody>
>                         <marshal ref="zipFileDataFormat" />
>                 </route>
>         </camelContext>
>
> Is there any options that can help me to do that successfully?
>
> Regards,
> Marc
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-restlet-zipped-response-tp5751420.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/