cloud.downloadfile not working in webgl build

Discussion and help for Easy Save 3
Post Reply
ConnorG
Posts: 4
Joined: Wed Aug 21, 2019 5:01 am

cloud.downloadfile not working in webgl build

Post by ConnorG »

HI all,
I'm trying to convert my project to webgl and I getting a cloud.error = Unknown error every time i try to load in data from my cloud server.
It works fine in the editor but when i make a build and host it on itch.io or run it locally through a edge browser the error occurs.
being an "unknown error" doesn't help too.
Am i doing something wrong? i'm pulling my hair out trying to figure this out

Code: Select all

 public IEnumerator DownloadProfiles()
    {
        Debug.Log("Downloading profiles");

        file = new ES3File(SchoolName + "UsersList.es3", false);
        ES3Cloud cloud = new ES3Cloud(url, apiKey);

        yield return cloud.DownloadFile(file);
        if (cloud.isError)
        {
            Debug.LogError(cloud.error);
            LoadError.gameObject.SetActive(true);
            LoadError.text = cloud.error;
            CantFindProfiles.SetActive(true);
            SelectAccountUI.SetActive(false);
            AccountNameUI.SetActive(true);
        }
        else
        {
            
            if (file.KeyExists(SchoolName + "Users"))
            {
                Debug.Log("found and Downloaded profiles");
                LoadingProfilesText.SetActive(false);
                Profiles = file.Load<List<SprayPainterProfilesList>>(SchoolName + "Users");
                dropdown.gameObject.SetActive(true);
                foreach (SprayPainterProfilesList p in Profiles)
                {
                    Debug.Log("adding profiles to dropdown");
                    dropdown.options.Add(new TMP_Dropdown.OptionData() { text = p.ProfileUsername });
                }
            }
}
}
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: cloud.downloadfile not working in webgl build

Post by Joel »

Hi Connor,

I replied to your email regarding this, but I'll post the main part of the response here in case it helps anyone else:

Is the ES3Cloud.php script on the same server as the WebGL application? If not, you will need to contact your server provider to enable CORS (see https://docs.unity3d.com/Manual/webgl-networking.html). WebGL requires that this is enabled for security reasons when communicating with remote servers.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply