I'm developing a J2ME client that must upload a file to a Servlet using HTTP.
The servlet part is covered using Apache Commons FileUpload
protected void doPost(HttpServletRequest request, HttpServletResponse response)
{
ServletFileUpload upload = new ServletFileUpload();
upload.setSizeMax(1000000);
File fileItems = upload.parseRequest(request);
// Process the uploaded items
Iterator iter = fileItems.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
File file = new File("\files\\"+item.getName());
item.write(file);
}
}
Commons Upload seems to be able to upload only multipart file, but no application/octect-stream.
But for the client side there are no Multipart classes, neither, in this case, is possible to use any HttpClient library.
Other option could be to use HTTP Chunk upload, but I haven't found a clear example of how this could be implemented, specially on the servlet side.
My choices are: - Implement a servlet for http chunk upload - Implement a raw client for http multipart creation
I don't know how to implement none of the above options. Any suggestion?