RECEIVING (client -> server)

What's the conventional wisdom on how best to let somebody send (upload) a file in a REST application (one built on JSR-311 annotations, in particular)? Seems like you could just let them PUT or POST the raw data, as an application/octet-stream... Is that better/worse than something that uses multipart/mixed? Need it be base-64 encoded? Anyway, looking for a best practice, if you will. How's this generally handled?

SENDING (server -> client)

On the flip side (sending a file back to the user when they GET the corresponding resource), is there anything you can do other than tag it as "application/octet-stream" (i.e. can you cause the right MIME type to be used)? Seems like the code has to advertise that it @Produces something specific, in which case application/octet-stream seems the most generic/safe. Not sure how you would determine (and alter) the MIME type on the fly -- especially since the data at the given resource could be any kind of file (in my case, the resource points to an arbitrary, previously-uploaded file).

Thanks!

Reply via email to