You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tfredrich <tf...@yahoo.com> on 2009/03/03 23:53:31 UTC

Re: Restlet Component File Upload Handling

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.


Re: Restlet Component File Upload Handling

Posted by William Tam <em...@gmail.com>.
Hi Todd,

Your usecase seems to justify use of camel-restlet.  For example, user
code will need to deal with RESTful URI and authentication if it is
using camel-jetty.  I'll create a Jira to support multipart message.

Cheers,
William

On Tue, Mar 3, 2009 at 5:53 PM, tfredrich <tf...@yahoo.com> wrote:
>
> 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.
>
>