FileUpload.writeToTempFile() fails with commons-fileupload 1.4
As of commons-fileupload 1.4, writing the uploaded file to a temp file with fileUpload.writeToTempFile() fails with the following exception:
This only happens when the file is larger than the size threshold of 10 kB (by default). In that case the uploaded content is already in a temp file and will be moved to the newly created temp file. Commons-fileupload 1.3.3 used File.rename() for this; in 1.4 the implementation has been changed to FileUtils.moveFile(), which does not allow the destination to be present.
To be functionally compatible with the old situation, FileUload.writeTo() should delete the provided file, if present, before writing.
See the provided test case.