After some research I decided to to upload my player's level progress which is huge dictionary in a text file as an entity file.
Following the link below,
https://docs.microsoft.com/en-us/gaming/playfab/features/data/entities/quickstart
I get the following error in PlayFabHttp.SimplePutCall() :
error CS1503: Argument 3: cannot convert from 'method group' to 'Action<byte[]>'
the method group it's talking about is void FinalizeUpload()
And how am i supposed to input my text file name here ? payloadstr?
Answer by Made Wang · Mar 21 at 07:56 AM
FinalizeUpload is a callback method, it needs to accept data, even if you don't use the data. Refer to the writing in the example:
void FinalizeUpload(byte[] data){}
In FinalizeUpload, you need to call FinalizeFileUploads to complete the file upload. The file name you need to pass in here should be the same as the file name you passed in when calling InitiateFileUploads. You can use it as a global variable.
PayloadStr refers to the content of this file, you need to convert it to a byte array and pass it as the second parameter in SimplePutCall.
Okay! I am successfully able to Put and Get a entity file, however it is empty.
My game basically generates a text file (savedtextfile.txt for examples), which is in my resources. How can I upload that file with data in it, onto playfab instead of actually making a new empty entity file named savedtextfile.txt
As said above, you need to convert the content of the file to a byte array and pass it as a parameter to SimplePutCall. If you are getting the file in Unity's resources folder you can refer to the code below, in addition, you can also use the IO stream to get the file.
TextAsset txt = Resources.Load("test") as TextAsset; string payloadStr = txt.text; byte[] payload = Encoding.UTF8.GetBytes(payloadStr); PlayFabHttp.SimplePutCall(response.UploadDetails[0].UploadUrl, payload, FinalizeUpload, error => { Debug.Log(error); } );
Thank you so much! Wasn't able to understand where to put my text. And how do I download it and retrieve the text within?
Okay! Got it. But I ended up using the url to download the file to my persistentDataPath and access it from there.
Ok, if you still have questions please feel free to let us know.