@PostMapping("/admin/upload-employee-pictures")
ResponseEntity<ApiSuccess> uploadEmployeeProfilePictures(@RequestParam("file") MultipartFile file) {
Map data = new HashMap();
try {
// Get the file name
String fileName = file.getOriginalFilename();
// Get the file content
byte[] bytes = file.getBytes();
// Write the file to the upload directory
FileOutputStream fos = new FileOutputStream("upload/" + fileName);
fos.write(bytes);
fos.close();
} catch (IOException e) {
System.out.println( "Error uploading file: " + e.getMessage());
}
return new ResponseEntity<>(new ApiSuccess(ApplicationResponseCode.SUCCESS_2032.getCode(), ApplicationResponseCode.SUCCESS_2032.getDescription(), data), HttpStatus.OK);
}
No comments:
Post a Comment