@ RequestMapping ( value = "/api/backup" , method = RequestMethod . POST ) public @ ResponseBody Backup processBackup ( @ RequestParam ( "fileData" ) MultipartFile fileData ) throws Exception { // Method taken from: http://spring.io/guides/gs/uploading-files/ if ( ! fileData . isEmpty ( ) ) { try { byte [ ] bytes = fileData . getBytes ( ) ; BufferedOutputStream stream = new BufferedOutputStream ( new FileOutputStream ( new File ( "backup-uploaded.json" ) ) ) ; stream . write ( bytes ) ; stream . close ( ) ; } catch ( Exception e ) { } } File f = new File ( "backup-uploaded.json" ) ; BackupService . getInstance ( ) . restoreBackupData ( new FileInputStream ( f ) ) ; return BackupService . getInstance ( ) . getBackupData ( ) ; }
Restore backup data