I'm trying to create a lightweight, self-contained webservice using the spark microframework ( http://www.sparkjava.com/readme.html ). I need to work with multi-part forms (I want to receive both a file, and some key-value data).
Jetty (on which Spark depends) provides a MultiPartFilter
filter which facilitates working with multipart data, but I don't understand how to hook into that in my code.
I need to do this programmatically because this service will not be deployed as part of a giant java installation, but to support a python application.
The code I have is along these lines:
public class Transcoder {
static Base64 base64 = new Base64();
public static void main(String[] args) {
org.apache.log4j.BasicConfigurator.configure();
post(new Route("/convert") {
@Override
public Object handle(Request request, Response response) /*throws Exception, Docx4JException*/{
//I want to do something like this:
new_request = new MultiPartFilter().process_my_request(request);
/* work with altered request*/
});
}
}
Is this possible?