PhoneGap FileTransfer to Java Servlet

Go To StackoverFlow.com

1

I am using PhoneGap 1.5 for an iOS app and I need to upload photos to a Java Servlet via the FileTransfer object. Has anyone done this before? The only examples I've seen utilize PHP and it's not clear to me what's going on when my servlet is invoked. Will post code shortly.

2012-04-05 21:36
by user1316326
Does PhoneGap FileTransfer send a HTTP multipart/form-data request according RFC2388 spec? If so, then you can just use the standard APIs to parse file uploads as outlined here http://stackoverflow.com/questions/2422468/how-to-upload-files-in-jsp-servlet/2424824#2424824 like as if it's coming from a HTML page - BalusC 2012-04-05 21:38
Yes, I was looking at this exact link. I've successfully created a servlet that handles the photo and additional parameters. Thank you for your response - user1316326 2012-04-07 01:37
Great. I reposted the comment as an answer - BalusC 2012-04-07 01:39


1

If the PhoneGap FileTransfer sends a HTTP multipart/form-data request conform the RFC2388 spec, then you could just use the standard request.getPart() method or, when you're still on Servlet version 2.5 or older, the Apache Commons FileUpload for this as outlined in detail in this answer: How to upload files to server using JSP/Servlet?

2012-04-07 01:39
by BalusC
Ads