Created
June 23, 2016 12:09
-
-
Save alincc/2078107276f7b2015b2002f03fb608d4 to your computer and use it in GitHub Desktop.
Save file to folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileService { | |
private static final Logger logger = Logger.getLogger(FileService.class); | |
@Override | |
public boolean uploadFile(MultipartFile file, FileInfo fileInfo) { | |
// Find folder to save the file | |
String fileDir = PropertiesUtil.getProperty("file.dir"); | |
// Create file | |
File f = new File(fileDir + fileInfo.getFileName()); | |
try { | |
// Write to file | |
FileUtils.writeByteArrayToFile(f, file.getBytes()); | |
} catch (IOException e) { | |
logger.error(e.getLocalizedMessage()); | |
return false; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment