I need the player to be able to upload and download small files to and from their application’s persistent data path. Here is the code I have right now:
IEnumerator UploadFileData()
{
string s_playerID = PlayFabManager.loggedInPlayfabId;
string s_levelID = PlayFabManager.levelID;
using (var uwr = new UnityWebRequest("https://example.com/", UnityWebRequest.kHttpVerbPUT))
{
string path = Path.Combine(Application.persistentDataPath, $"{s_playerID}{s_levelID}.replay");
uwr.uploadHandler = new UploadHandlerFile(path);
yield return uwr.SendWebRequest();
if (uwr.result != UnityWebRequest.Result.Success)
Debug.LogError(uwr.error);
else
{
Debug.Log("File successfully uploaded.");
}
}
}
IEnumerator DownloadFile()
{
string l_playerID = PlayFabManager.load_PlayfabId;
string l_levelID = PlayFabManager.load_levelID;
var uwr = new UnityWebRequest("https://example.com/", UnityWebRequest.kHttpVerbGET);
string path = Path.Combine(Application.persistentDataPath, $"{l_playerID}{l_levelID}.replay");
uwr.downloadHandler = new DownloadHandlerFile(path);
yield return uwr.SendWebRequest();
if (uwr.result != UnityWebRequest.Result.Success)
Debug.LogError(uwr.error);
else
Debug.Log("File successfully downloaded and saved to " + path);
}
The code needs to ID which player made the file and what level the file was made on, if you were curious what the “s_playerID” stuff is. I understand I need to replace the “https://example.com/” with a URL to send and receive the data, but I don’t know of a file hosting service to use and how to get the proper URL from it. It would be nice if I could just do it with dropbox or google drive, but I hear its not that simple. Are there any free file hosting services that would fit my needs here? Since the files are so small, I can make do with pretty tight storage limits. Any suggestions are super appreciated!