long streamLength = -1L;
try {
String sessionIdKey = WOApplication.application().sessionIdKey();
String sessionId = request.cookieValueForKey(sessionIdKey);
WOMultipartIterator multipartIterator = request.multipartIterator();
if (multipartIterator == null) {
response.appendContentString("Already Consumed!");
}
else {
WOMultipartIterator.WOFormData formData = null;
while ((formData = multipartIterator.nextFormData()) != null) {
String name = formData.name();
if (sessionIdKey.equals(name)) {
sessionId = formData.formValue();
}
else if ("id".equals(name)) {
uploadIdentifier = formData.formValue();
}
else if (formData.isFileUpload()) {
uploadFileName = request.stringFormValueForKey(name + ".filename");
streamLength = multipartIterator.contentLengthRemaining();
uploadInputStream = formData.formDataInputStream();
break;
}
}
context._setRequestSessionID(sessionId);