public static File saveToTempFile ( Part part ) throws IOException { String filename = getOriginalFileName ( part ) ; if ( filename == null ) { return null ; } File file = File . createTempFile ( "molgenis-" , "." + StringUtils . getFilenameExtension ( filename ) ) ; FileCopyUtils . copy ( part . getInputStream ( ) , new FileOutputStream ( file ) ) ; return file ; }
Saves an uploaded file to a tempfile with prefix molgenis - keeps the original file extension