Combu  3.2.2
Unity API Documentation
Managing Files

In this section you will learn how to retrieve the files lists of the local user or anyway accessible by him and how to add/remove files.

Loading Files

To retrieve a list of files you need to call UserFile.Load:

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);
else
Debug.Log(error);
});

Adding Files

To add a file associated to the local user you need to create a new instance of UserFile, set sharing property and call Update:

byte[] screenshot = CombuManager.instance.CaptureScreenShot();
UserFile newFile = new UserFile();
newFile.sharing = UserFile.eShareType.Everybody;
newFile.customData ["Prop"] = "Value";
newFile.Update(screenshot, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});

Viewing Files

To increase the View count of a file you need to call UserFile.View, or call the method View on a UserFile instance:

// View by File ID
UserFile.View(123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
// View by UserFile object
myFile.View( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});

Liking Files

To increase the Like count of a file you need to call UserFile.Like, or call the method Like on a UserFile instance:

// Like by File ID
UserFile.Like(123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
// Like by UserFile object
myFile.Like( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});

Removing Files

To remove a file owned by the local user you need to call UserFile.Delete, or call the method Delete on a UserFile instance:

// Remove by File ID
UserFile.Delete(123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
// Remove from a UserFile object
myFile.Delete( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});