I'm submitting a multipart form that contains a "file" type input. I'm using this input to upload images. The form submits to a servlet that then passes the uploaded file information to a node app (using an API call) which stores the file.
My issue is that this doesn't work with most of the files I'm trying to upload. In some cases, it does work, but I couldn't find anything unique in these files.
The error I'm getting is:
[INFO] [talledLocalContainer] caused by: java.io.FileNotFoundException: < absolute-path-to-temp-dir>\temp\upload_1940e046_658b_40ae_9d6d_4a1ecac4e58d_00000083.tmp (The system cannot find the file specified)
Below is the function that fails:
protected HttpResponse postUpdateBadge(String url, JSONObject payload)throws IOException {
HttpClient httpClient = HttpClientBuilder.create().build();
HttpEntityEnclosingRequestBase httpCall = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(payload.has("file")) {
DiskFileItem dfi = (DiskFileItem) payload.get("file");
if (!dfi.getName().equals("")) {
builder.addBinaryBody("icon", dfi.getStoreLocation(), ContentType.create(dfi.getContentType()), dfi.getName());
}
payload.remove("file");
}
builder.addPart("payload", new StringBody(payload.toString(), ContentType.APPLICATION_JSON));
httpCall.setEntity(builder.build());
httpCall.setHeader("token", token);
return httpClient.execute(httpCall);
}
When trying to submit a form with a file, I get the above error. When trying to debug the code, I notice that in no point in time is there actually a file with the given name in the destination directory.
What am I doing wrong?
Stack trace below -
[INFO] [talledLocalContainer] com.atlassian.confluence.web.filter.validateparam.RequestParamValidationFilter_already_filtered: true
[INFO] [talledLocalContainer] atlassian.core.seraph.original.url: /500page.jsp
[INFO] [talledLocalContainer] com.atlassian.confluence.security.websudo.MessagesDecoratorFilter__already_filtered__: true
[INFO] [talledLocalContainer] com.atlassian.labs.botkiller.BotKillerFilter: true
[INFO] [talledLocalContainer] com.atlassian.gzipfilter.GzipFilter_already_filtered: true
[INFO] [talledLocalContainer] Confluence-Request-Time: 1439296917003
[INFO] [talledLocalContainer] loginfilter.already.filtered: true
[INFO] [talledLocalContainer] javax.servlet.error.request_uri: /confluence/plugins/servlet/wspoints/badge/edit
[INFO] [talledLocalContainer] com.atlassian.core.filters.HeaderSanitisingFilter_already_filtered: true
[INFO] [talledLocalContainer] com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFixupFilter: true
[INFO] [talledLocalContainer] com.atlassian.confluence.web.ConfluenceJohnsonFilter_already_filtered: true
[INFO] [talledLocalContainer] javax.servlet.error.exception: java.io.FileNotFoundException: C:\Users\User\IdeaProjects\points-system\target\container\tomcat6x\cargo-confluence-home\temp\upload_1940e046_658b_40ae_9d6d_4a1ecac4e58d_00000139.tmp (The system cannot find the file specified)
[INFO] [talledLocalContainer] os_securityfilter_already_filtered: true
[INFO] [talledLocalContainer] com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFilter: true
[INFO] [talledLocalContainer] --------------------------
[INFO] [talledLocalContainer] Parameters
[INFO] [talledLocalContainer] --------------------------
[INFO] [talledLocalContainer] caused by: java.io.FileNotFoundException: C:\Users\User\IdeaProjects\points-system\target\container\tomcat6x\cargo-confluence-home\temp\upload_1940e046_658b_40ae_9d6d_4a1ecac4e58d_00000139.tmp (The system cannot find the file specified)
[INFO] [talledLocalContainer] at java.io.FileInputStream.open0(Native Method)
[INFO] [talledLocalContainer]