Page 1 of 1

(Solved - issue was on my server side) Issues with the upload/download code example

Posted: Tue Sep 08, 2020 2:38 pm
by Chimar
Hey Joel,

I was using the code example found at https://moodkie.com/forum/viewtopic.php?f=16&t=1707 but i cant seem to get it to work. heres exactly what my code looks like except for the server data which i removed:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DBConnect : MonoBehaviour
{

    // Your ES3Cloud.php details
    public string url = "";
    public string apiKey = "";

    // The variables you want to upload/download.
    int myInt = 123;
    Vector3 myVector3 = new Vector3(1f, 2f, 3f);

    // Call these to upload or download.
    public void Upload() { StartCoroutine(UploadRoutine()); }
    public void Download() { StartCoroutine(DownloadRoutine()); }


    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(UploadRoutine());
    }

    // Update is called once per frame
    void Update()
    {
        
    }



    private IEnumerator UploadRoutine()
    {
        // Create a new ES3File, and ensure we specify false as the parameter
        // so that we don't sync it to local storage
        Debug.Log("Uploading...");
        var file = new ES3File(false);

        // Save data to our ES3File in memory.
        file.Save<int>("myInt", myInt);
        file.Save<Vector3>("myVector3", myVector3);

        // Create an ES3Cloud and upload the file.
        var cloud = new ES3Cloud(url, apiKey);
        yield return cloud.UploadFile(file);

        // If an error occurs, log it to console.
        if (cloud.isError)
            Debug.LogError(cloud.error);
        else
            Debug.Log("Uploaded");
    }

    private IEnumerator DownloadRoutine()
    {
        // Create a new ES3File, and ensure we specify false as the parameter
        // so that we don't sync it to local storage
        var file = new ES3File(false);
        // Create an ES3Cloud and download the file.
        var cloud = new ES3Cloud(url, apiKey);
        yield return cloud.DownloadFile(file);

        if (cloud.isError)
            Debug.LogError(cloud.error);
        else
            Debug.Log("Downloaded");

        // Load the data from the ES3File and back into our variables.
        // We set the defaultValue parameter incase data doesn't exist.
        myInt = file.Load<int>("myInt", 0);
        myVector3 = file.Load<Vector3>("myVector3", Vector3.zero);
    }
it all seems to work until it gives me the error "uploaded file does not exist or is empty". before it gives me the "(writing property)" logs id expect and a "Committing backup for SaveFile.es3 to storage location InternalMS" before the error.

Thanks!

Re: Issues with the upload/download code example

Posted: Tue Sep 08, 2020 3:55 pm
by Joel
Hi there,

Please could you private message me a basic project which replicates this so I can see what is happening? It's not possible to tell from your code.

All the best,
Joel

Re: Issues with the upload/download code example

Posted: Mon Sep 14, 2020 9:59 am
by Chimar
Hi,

Sorry for taking so long to reply.

The code I have is exactly like the one provided in the tutorial from the forum link I included, the only thing i changed is i added my own server URL and API key (which i edited out of the post) and called the Upload() function on start as " StartCoroutine(UploadRoutine());". I included here an image of the console because I realize I explained that quite poorly above.

Console:
https://drive.google.com/file/d/1vhU2oM ... sp=sharing

My Settings:
https://drive.google.com/file/d/1uEMpOJ ... sp=sharing

the error that i get leads me to believe that it's not an issue with the server since that appears to have be configured correctly (the SQL DB has the Es3Cloud table) but instead some issue with how the function goes looking for the file.

I tried both Files i had in my directory and the tutorial's method which is supposed to upload to the DB without ever creating a local file and they gave the same error.

thanks!

Re: Issues with the upload/download code example

Posted: Mon Sep 14, 2020 2:01 pm
by Joel
Hi there,

I get access denied for the link you've posted. Please could you paste the error you're getting into a message so I can see it?

Also judging by what you've said previously it sounds like you might have the save location set to InternalMS. Have you changed this to InternalMS anywhere?

All the best,
Joel

Re: Issues with the upload/download code example

Posted: Tue Sep 15, 2020 9:41 am
by Chimar
Hey there,

My bad, i had forgotten to set drive to anyone with link. I changed it and added a photo of my settings too.

I believe the internalMS thing is due to using the Forum Tutorial's saving without generating a local file thing as when I create a file like i normally would for a .csv or .es3 it saves to the persistent data path.

just to double check i tested it here with a es3spreadsheet.save() and it works as intended:
https://drive.google.com/file/d/18BG8W_ ... sp=sharing

Thanks!

Re: Issues with the upload/download code example

Posted: Tue Sep 15, 2020 10:30 am
by Joel
Hi there,

Unfortunately it's still not possible to tell what is happening from what you've sent. Please could you create a new project with a basic scene which replicates your issue and private message it to me?

All the best,
Joel

Re: Issues with the upload/download code example

Posted: Tue Sep 15, 2020 10:35 am
by Chimar
sure, will do!

Re: Issues with the upload/download code example

Posted: Tue Sep 15, 2020 1:51 pm
by Chimar
sent it!

Re: (Solved - issue was on my server side) Issues with the upload/download code example

Posted: Mon Sep 28, 2020 11:23 am
by Chimar
Issue is solved - the person who setup the server I was given to work with didn't set it up properly and it didn't have a temp folder.

Joel kindly helped me debug it and figure out what the issue was.