Profile Picture Sys...
 
Notifications
Clear all

Profile Picture System

5 Posts
2 Users
0 Reactions
940 Views
(@pixelcoder)
Posts: 7
Active Member
Topic starter
 

Hi friends,

I'm very new in using Combu, I learned it very quickly (good documentation & example), but I got stuck by implementation of an profile system, I tried a lot of things but no succes. I think that will be much appreciated if the Combu Team will create an example how to achieve thiswub.

Thanks in advance!

 
Posted : 15/08/2016 5:59 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

If the user can upload his profile picture then you should use UserFile (you can set the name in the UserFile properties that is the same for pictures of all users like "picture" and check this name in the list of files of a user from the results returned by UserFile.Load), else if the pictures are predefined and the user can only select one of them then you can store the picture index in the customData of User.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 17/08/2016 12:19 am
(@pixelcoder)
Posts: 7
Active Member
Topic starter
 

Hi,

I tried what you suggested, but I can't load the picture from server error 404 Not found :(, this is my test script:

*What is wrong, thanks in advance!

public void SEND_IMAGE_TO_SERVER()
{
StartCoroutine(CreateSendScreenshot());
}
private IEnumerator CreateSendScreenshot()
{
yield return new WaitForEndOfFrame();
// Create a texture the size of the screen, RGB24 format
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();

byte[] image = tex.EncodeToPNG();
UserFile newFile = new UserFile();
newFile.sharing = UserFile.eShareType.Everybody;
newFile.name = "avatar_" + CombuManager.localUser.userName;
newFile.Update(image, (bool success, string error) => {
if (success)
DebugTest("upload",newFile.name, newFile.url, "success");
else
DebugTest("upload", newFile.name, newFile.url, error);
});

Destroy(tex);
}

public void LOAD_IMAGE_FROM_SERVER()
{
bool includeShared = true;
int pageNumber = 1;
int countPerPage = 10;
UserFile.Load(CombuManager.localUser.id, includeShared, pageNumber, countPerPage, (UserFile[] files, int resultsCount, int pagesCount, string error) => {
if (string.IsNullOrEmpty(error))
{
Debug.Log("Files loaded: " + files.Length);
StartCoroutine(DownloadFile(files[0].url, files[0].name));
}
else
Debug.Log(error);
});
}

IEnumerator DownloadFile(string _urlFile, string _fileName)
{
WWW www = new WWW(_urlFile);
yield return www;

if (www.error == null)
{
yield return new WaitForSeconds(0.2f);
localImageTest.texture = www.texture;
DebugTest("download", _fileName, _urlFile, "SUCCESS!");
}
else
{
DebugTest("download", _fileName, _urlFile, www.error);
}
}

private void DebugTest(string _action, string _fileName, string _fileUrl, string _status)
{
switch (_action)
{
case "upload":
textDebug.text = "FILE: " + _fileName + " uploaded here: " + _fileUrl + " " + _status;
Debug.Log("FILE: " + _fileName + " uploaded here: " + _fileUrl + " " + _status);
break;

case "download":
textDebug.text = "FILE: " + _fileName + " downloaded from: " + _fileUrl + " " + _status;
Debug.Log("FILE: " + _fileName + " downloaded from: " + _fileUrl + " " + _status);
break;
}
}

 

 
Posted : 19/08/2016 5:48 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I tested your function LOAD_IMAGE_FROM_SERVER() and it works, DebugTest() prints in the console log "FILE: downloaded from: SUCCESS!" and the URL is correct.

What is it returning to you as URL? Have you set the constant URL_ROOT (in config.php) to the correct folder of Combu relative to the root of your web server?

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 23/08/2016 4:23 pm
Share: