Sign In Register

How can we help you today?

Start a new topic

Tracking Uploaded Files

I'm following along the tutorial on uploading binary content via unity's www to the player's database in xml format on the cloud.


After uploading the file, I use the UploadComplete message to create a link in the player's scriptData to track what files they've uploaded.

A player can have multiple files like: compendium or spells.



Now, my question is that I would like to save the file after it has completed downloading and I do that by creating a new event once I receive the UploadComplete message. But I would like to know who sent the file. Is it possible to add parameters via the www form and is there a way to retrieve this from the UploadCompleteMessage?


Additionally, is there a better way to create the upload links without needing to go thru the UploadCompleteMessage?


Code snippet below:


Thanks


========================================

public IEnumerator UploadAFile(byte[] content, string uploadUrl) { yield return new WaitForEndOfFrame(); // Create a Web Form, this will be our POST method's data var form = new WWWForm(); form.AddBinaryData("file", content, "compendium.xml"); //POST the screenshot to GameSparks WWW w = new WWW(uploadUrl, form); yield return w; if (w.error != null) { Debug.Log(w.error); } else { Debug.Log(w.text); } } //This will be our message listener, this will be triggered when we successfully upload a file public void GetUploadMessage(GSMessage message) { //Every time we get a message Debug.Log(message.BaseData.GetString("uploadId"));



new GameSparks.Api.Requests.LogEventRequest()
                      .SetEventKey("UploadCloud")
                      .SetEventAttribute("Param", "{\"system\":\"5e\",\"myFile\":\""+ message.BaseData.GetString("uploadId") +"\"}")
                      .Send((response) => {
            if (!response.HasErrors)
            {
                Debug.Log("Data Saved To GameSparks...");
            }
            else
            {
                Debug.Log("Error Saving Data...");
            }
        });
}

Login to post a comment