Add file upload routes.

This commit is contained in:
2018-05-18 20:39:49 +02:00
parent c62de5d6ed
commit 5f54a8e592
6 changed files with 170 additions and 1 deletions
@@ -11,19 +11,25 @@ import org.codiki.core.entities.dto.UserDTO;
import org.codiki.core.entities.persistence.User;
import org.codiki.core.repositories.UserRepository;
import org.codiki.core.security.TokenService;
import org.codiki.core.services.FileUploadService;
import org.codiki.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@Service
public class AccountService {
@Autowired
private UserRepository userRepository;
@Autowired
private TokenService tokenService;
@Autowired
private FileUploadService fileUploadService;
/**
* Check the user credentials and generate him a token if they are correct.
*
@@ -68,4 +74,12 @@ public class AccountService {
"Le mot de passe saisi ne correspond pas au votre.");
}
}
public String uploadFile(final MultipartFile pFile) {
return fileUploadService.uploadProfileImage(pFile);
}
public Resource loadAvatar(final String pAvatarFileName) {
return fileUploadService.loadAvatar(pAvatarFileName);
}
}