Image issue solve

This commit is contained in:
2025-10-13 20:08:14 +05:30
parent 9643c762d5
commit 41824cfc38

View File

@ -78,16 +78,19 @@ public class ProfessorServiceImpl implements ProfessorService {
return addNewProfessor(professorDto);
}
// ✅ FIXED: Changed from DEFAULT_USER_IMAGE_URI_PATTERN to DEFAULT_PROFESSOR_IMAGE_URI_PATTERN
private String generateDefaultProfileImageUrl(UUID professorId) {
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.path(String.format(DEFAULT_PROFESSOR_IMAGE_URI_PATTERN, professorId))
.toUriString();
}
// ✅ FIXED: Changed from DEFAULT_USER_IMAGE_URI_PATTERN to DEFAULT_PROFESSOR_IMAGE_URI_PATTERN
// ✅ FIXED: Changed from USER_IMAGE_FILENAME to PROFESSOR_IMAGE_FILENAME
private String generateProfileImageUrl(UUID professorId) {
return ServletUriComponentsBuilder.fromCurrentContextPath()
.path(String.format(DEFAULT_USER_IMAGE_URI_PATTERN, professorId))
.pathSegment(USER_IMAGE_FILENAME)
.path(String.format(DEFAULT_PROFESSOR_IMAGE_URI_PATTERN, professorId))
.pathSegment(PROFESSOR_IMAGE_FILENAME)
.toUriString();
}
@ -131,6 +134,7 @@ public class ProfessorServiceImpl implements ProfessorService {
.orElseThrow(() -> new ProfessorNotFoundException(PROFESSOR_NOT_FOUND_MSG));
}
// ✅ FIXED: Changed from USER_IMAGE_FILENAME to PROFESSOR_IMAGE_FILENAME
private void saveProfileImage(Professor professor, MultipartFile profileImage) {
if (profileImage == null) return;
@ -138,7 +142,7 @@ public class ProfessorServiceImpl implements ProfessorService {
throw new NotAnImageFileException(profileImage.getOriginalFilename() + " is not an image file. Please upload an image");
}
String imageUrl = profileImageService.persistProfileImage(professor.getProfessorId(), profileImage, USER_IMAGE_FILENAME);
String imageUrl = profileImageService.persistProfileImage(professor.getProfessorId(), profileImage, PROFESSOR_IMAGE_FILENAME);
if (imageUrl == null)
imageUrl = generateProfileImageUrl(professor.getProfessorId());