camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfredrich <tfredr...@yahoo.com>
Subject Re: Restlet Component File Upload Handling
Date Tue, 03 Mar 2009 22:53:31 GMT

As usual, one thing calls for another...  I created a MultipartRestletBinder
that simply overrides populateExchangeFromRestletRequest(), checks for
multipart content, and leverages the FileUpload extension if applicable. 
However, once that operated appropriately (for my case of uploading images),
I discovered that the download case assumes the body to be a string. 
Consequently, I overrode populateRestletResponseFromExchange() and serialize
a byte array for the case of IMAGE MediaType.  See attached 
http://www.nabble.com/file/p22319865/MultipartRestletBinding.java
MultipartRestletBinding.java 

Quite likely, you might ask (as I now am) why use Camel-Restlet to
read/write images...  The basic use cases are:

Upload:
1) Upload image for user using RESTful URI.
2) Authenticate user.
3) Hash name to make the filename unique.
4) Write the image to the unique filename (on virtual storage).
5) Update user data to reference newly uploaded image.

Download:
1) Request image for user via RESTful URI (with hashed filename).
2) Authenticate user
3) Return image.

Apache (httpd) is certainly faster for such static content.  I'm open to
suggestions--especially as to how to better utilize Camel (with or without)
the restlet component to localize authentication, present a RESTful service
interface (with tidy URIs), etc.

Thanks again,
--Todd Fredrich
-- 
View this message in context: http://www.nabble.com/Restlet-Component-File-Upload-Handling-tp22250082p22319865.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Mime
View raw message