question

anudeep avatar image
anudeep asked

Trouble uploading a text file as an entity file onto playfab.

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?

Player Dataunity3dentitiesdata
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Made Wang avatar image
Made Wang answered

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.

8 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

anudeep avatar image anudeep commented ·

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

0 Likes 0 ·
Made Wang avatar image Made Wang anudeep commented ·

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); }
);
0 Likes 0 ·
anudeep avatar image anudeep Made Wang commented ·

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?

0 Likes 0 ·
Show more comments
anudeep avatar image anudeep anudeep commented ·

Okay! Got it. But I ended up using the url to download the file to my persistentDataPath and access it from there.

0 Likes 0 ·
Made Wang avatar image Made Wang anudeep commented ·

Ok, if you still have questions please feel free to let us know.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.