Some logs added
This commit is contained in:
parent
cb0b6505b3
commit
5ffd345e7e
|
@ -28,23 +28,33 @@ public class MinioAvatarStorageProvider implements AvatarStorageProvider {
|
|||
|
||||
@Override
|
||||
public void saveAvatarImage(RealmModel realmModel, UserModel userModel, InputStream input) {
|
||||
execute(minioClient -> minioClient
|
||||
.putObject(PutObjectArgs.builder().bucket(configuration.rootBucket).object(getAvatarFilePath(
|
||||
realmModel, userModel)).stream(input, -1, CHUNK_SIZE).build()));
|
||||
logger.debugf("Saving avatar to S3 for user: %s", userModel.getUsername());
|
||||
execute(minioClient -> {
|
||||
String avatarFileName = getAvatarFilePath(realmModel, userModel);
|
||||
logger.tracef("Saving avatar file object as: %s", avatarFileName);
|
||||
return minioClient
|
||||
.putObject(PutObjectArgs.builder().bucket(configuration.rootBucket).object(avatarFileName)
|
||||
.stream(input, -1, CHUNK_SIZE).build());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream loadAvatarImage(RealmModel realmModel, UserModel userModel) {
|
||||
logger.debug("Loading avatar from S3");
|
||||
logger.debugf("Loading avatar from S3 for user: %s", userModel.getUsername());
|
||||
return execute(new Executor<InputStream>() {
|
||||
public InputStream execute(MinioClient minioClient) throws Exception {
|
||||
try {
|
||||
String avatarFileName = getAvatarFilePath(realmModel, userModel);
|
||||
logger.tracef("Getting avatar file object: %s", avatarFileName);
|
||||
return minioClient
|
||||
.getObject(GetObjectArgs.builder().bucket(configuration.rootBucket).object(getAvatarFilePath(
|
||||
realmModel, userModel)).build());
|
||||
.getObject(
|
||||
GetObjectArgs.builder().bucket(configuration.rootBucket).object(avatarFileName)
|
||||
.build());
|
||||
} catch (ErrorResponseException e) {
|
||||
if (e.response().code() == 404) {
|
||||
logger.debugf("Avatar file not found for user '%s' in realm '%s'", userModel.getUsername(), realmModel.getName());
|
||||
logger.debugf("Avatar file not found for user '%s' in realm '%s'", userModel.getUsername(),
|
||||
realmModel.getName());
|
||||
|
||||
return null;
|
||||
} else {
|
||||
throw e;
|
||||
|
@ -56,10 +66,13 @@ public class MinioAvatarStorageProvider implements AvatarStorageProvider {
|
|||
|
||||
@Override
|
||||
public void deleteAvatarImage(RealmModel realmModel, UserModel userModel) {
|
||||
logger.debug("Deeleting avatar from S3");
|
||||
logger.debugf("Deleting avatar from S3 for user: %s", userModel.getUsername());
|
||||
execute(minioClient -> {
|
||||
String avatarFileName = getAvatarFilePath(realmModel, userModel);
|
||||
logger.tracef("Deleting avatar file object: %s", avatarFileName);
|
||||
minioClient.removeObject(RemoveObjectArgs.builder().bucket(configuration.rootBucket)
|
||||
.object(getAvatarFilePath(realmModel, userModel)).build());
|
||||
.object(avatarFileName).build());
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue