Upload Chatter Profile Pic Using Apex
ConnectApi makes out job easier, using connectAPi we can achieve this as follows
blob picContect = res.getBodyAsBlob();
// get content into picContent(of Blog Type)
ConnectApi.BinaryInput fileUpload = new ConnectApi.BinaryInput(picContect,
'image/jpg', '<<Pic Name>>');
ConnectApi.Photo photoProfile = ConnectApi.ChatterUsers.setPhoto(<<communityId>>, userId, fileUpload);
Tada!!! thats it!
Input of Community Id goes likes this