Hello again,
I'm now trying to create a system for storing the player's saves in Combu. So I understand that to get the files on the server I need to call UserFile.Load, and I'll get an array of UserFile objects as a result. However, I don't know what I'm supposed to do next. I'd like to examine the contents of those files and then if necessary save them on the hard drive. However, there doesn't seem to be anything like
byte[] UserFile.GetContents()
or such. All I see is an URL field - am I supposed to use that to download the actual file?
Thanks again for any help you can give.
Just as you would usually do to download any file: with WWW.
You can also add this method to UserFile and call Download on a UserFile, it will be in the next update:
{
CombuManager.instance.StartCoroutine(DownloadUrl(callback));
}
IEnumerator DownloadUrl (Action<byte[]> callback)
{
byte[] bytes = new byte[0];
if (!string.IsNullOrEmpty(url))
{
WWW wwwUrl = new WWW(url);
yield return wwwUrl;
if (string.IsNullOrEmpty(wwwUrl.error))
bytes = wwwUrl.bytes;
}
if (callback != null)
callback(bytes);
}
FRANCESCO CROCETTI @ SKARED CREATIONS
Thanks for the clarification!
I was confused because there seems to be constructors for UserFile with a JSON or a Hashtable, so it looked like as if the UserFile class itself contains the data. But I suppose it's just a sort of a header then.
Yes, all classes have constructors/accessor methods to set their data from JSON/Hashtable but the list web services only return the JSON to initialize the class (it would be harmful to download the contents of all files in a list, since it could even be MB or more).
FRANCESCO CROCETTI @ SKARED CREATIONS
Thanks, that makes sense (though more documentation wouldn't hurt).
One suggestion, though: It would be nice to be able to add some kind of custom info to the UserFile object itself that you can check without downloading the entire file. Some kind of a custom header. For example a timestamp for when it was last updated. As it it, it seems I'll have to download all our files anyway before I can know which ones I actually need.