file uploads with restlet
I'm writing a web service with restlet which involved file uploading and downloading. Downloading is simple enough, but file uploading seemed to be a more confusing topic.
Using HTTP POST and files represented by a form field, there are lots of ways to handle file uploads. Restlet includes the Apache FileUpload library, and I even read about using the MimePull library from Glassfish to achieve a streaming upload so you can process the files without having huge temp files.
In the end, I just used HTTP PUT which is superior in a variety of ways, and fit my needs well. It's not for getting files out of a form submission, but if your client can do the PUT, it's a good choice. For PUT uploads, there is no mime encoding which happens on the file, and it's just included raw as the HTTP body.
Parsing it on the restlet side is as easy as using entity.getStream() in the handlePut() method in your file resource. No futzing around with libraries or anything. Ta-da!


Post new comment