I've got a java function that generates digital signatures for xml files. Here's an excerpt that is giving me some trouble:
String boundary = MultiPartFormOutputStream.createBoundary();
HttpURLConnection urlConn = (HttpURLConnection)MultiPartFormOutputStream.createConnection(new URL(url + "/sign"));
urlConn.setRequestProperty("Accept", "*/*");
urlConn.setRequestProperty("Content-Type", MultiPartFormOutputStream.getContentType(boundary));
urlConn.setRequestProperty("Cache-Control", "no-cache");
urlConn.setDOInput(true);
urlConn.setDoOutput(true);
MultiPartFOrmOutputStream up = new MultiPartFormOutputStream(urlCOnn.getOutputStream(), boundary);
up.writeField(SignServletParams.detachedParam, "1");
up.writeFile(SignServletParams.xmlParam, "text/xml", "xml_file.xml", XMLUtil.toEncodedStream(doc);
up.close();
Document ret = null;
String connRead = "";
BufferedReader down = new BufferedReader(new InputStreamReader(urlCOnn.getINputStream()));
If I try and upload small xml files it works fine, however, if the xml file is larger (has a few thousand nodes), I get an IOException where the BufferedReader down is being created. The exception message just states that the server returned a 500 status. I checked the Apache server logs and it reports the following:
Input filter: failed to create temporary file: "file name"
I've inherited this code from someone else that wrote it, so I'm still trying to piece everything together, but any insight as to why the function works for small files and fails for larger ones would be appreciated.