Social Meal - social application - Add user avatar

Words
256
Reading
2 min
Listen
Play
8y

New Features

Upload avatar

In this contribution I focused about possibility to upload own avatar. Users have now possibility to add their avatar, this avatar is displaying in their profile and also as their thumbnail in the events which their participated or will be participate. Image is saving on the server and in database is stored information about localization. We dont want to store a full image, because it required a lot of space, so we create a thumbnail from photo, thumbanils is much smaller but quality i very good. User can also update his avatar, after update his old photo is deleted.

screenshot from swagger with this method:

image.png

Implementation

pull request:

image.png

commit connected wit this contribution

Implementation contain :

  • creating new service: ImageService, witch has couple of methods, main methods is responsible for take a photo as stream. Then is checking if photo has correct format, I decided also to check a EXIF orientation parameter, because photos made by Samsung Galaxy are often rotated, and if I will save it in original way, they will be displaying in application incorrectly. The rest of the methods are responsible for read image size, resizing, delete old photos and validate image format
  • methods in profileService witch are responsible for update particular user information about path to his avatar,
  • method in ProfileController to get avatar by Put method and return the path to user avatar.

Links related to this contribution



Posted on Utopian.io - Rewarding Open Source Contributors

Social Meal - social application - Add user avatar | Ecency