Search in sources :

Example 1 with FileUtils.copyFile

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;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) StoredFile(org.apache.openmeetings.util.StoredFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile) ProcessResultList(org.apache.openmeetings.util.process.ProcessResultList)

Aggregations

File (java.io.File)1 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)1 User (org.apache.openmeetings.db.entity.user.User)1 StoredFile (org.apache.openmeetings.util.StoredFile)1 ProcessResultList (org.apache.openmeetings.util.process.ProcessResultList)1