The action in KnowWE parsing the HTTP POST#
...
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
...
public class ReceiveJenkinsFileAction extends AbstractAction {
@Override
public void execute(UserActionContext context) throws IOException {
try {
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(context.getRequest());
for (FileItem item : items) {
System.out.println(item.getFieldName());
System.out.println(item.getName());
InputStream filecontent = item.getInputStream();
InputStreamReader is = new InputStreamReader(filecontent);
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(is);
String read = br.readLine();
while (read != null) {
sb.append(read);
read = br.readLine();
}
System.out.println(sb.toString());
}
}
catch (FileUploadException e) {
e.printStackTrace();
}
}
}