App-Engine (Java) File Upload
file, google-app-engine, java, upload
Solution
You have to go through the FileItemIterator. In the example you mentioned, only the image is processed (`FileItemStream imageItm = iter.next();`).
// From the example: http://stackoverflow.com/questions/1513603/how-to-upload-and-store-an-image-with-google-app-engine-java
FileItemIterator iter = upload.getItemIterator(req);
// Parse the request
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
InputStream stream = item.openStream();
if (item.isFormField()) {
System.out.println("Form field " + name + " with value "
+ Streams.asString(stream) + " detected.");
} else {
// Image here.
System.out.println("File field " + name + " with file name "
+ item.getName() + " detected.");
// Process the input stream
...
}
}
See http://www.jguru.com/faq/view.jsp?EID=1045507 for more details.
Problem
I managed to upload files on App-Engine by using the following example: How to upload and store an image with google app engine (java) and How to upload pics in appengine java The problem is, I am submitting other fields along with file field as listed below: ``` <form action="index.jsp" method="post" enctype="multipart/form-data"> <input name="name" type="text" value=""> <br/> <input name="imageField" type="file" size="30"> <br/> <input name="Submit" type="submit" value="Sumbit"> </form> ``` In my servlet, I am getting null when querying ``` name = request.getParameter("name"); ``` Why it is so? Is there a way to retrieve text field value?