Closing the temporary file before notifying about upload completion

mkstemp() opens the file with O_EXCL, so notifying upload handler about completion before actually closing the file can lead to a race condition where the handler fails to open() the file because the close() on the original file descriptor returned by mkstemp() has not been called yet.