use of org.apache.commons.io.FileUtils.copyFile in project openmeetings by apache.
the class ImageConverter method convertImageUserProfile.
public ProcessResultList convertImageUserProfile(File file, Long userId, boolean skipConvertion) throws Exception {
ProcessResultList returnMap = new ProcessResultList();
// User Profile Update
File[] files = getUploadProfilesUserDir(userId).listFiles(fi -> fi.getName().endsWith(EXTENSION_JPG));
if (files != null) {
for (File f : files) {
FileUtils.deleteQuietly(f);
}
}
File destinationFile = OmFileHelper.getNewFile(getUploadProfilesUserDir(userId), PROFILE_FILE_NAME, EXTENSION_JPG);
if (!skipConvertion) {
returnMap.add(convertSingleJpg(file, destinationFile));
} else {
FileUtils.copyFile(file, destinationFile);
}
if (!skipConvertion) {
// Delete old one
file.delete();
}
String pictureuri = destinationFile.getName();
User us = userDao.get(userId);
us.setUpdated(new java.util.Date());
us.setPictureuri(pictureuri);
userDao.update(us, userId);
return returnMap;
}
Aggregations