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

Discussion and help for Easy Save 3
Post Reply
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

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

Post 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!
Last edited by Chimar on Mon Sep 28, 2020 11:21 am, edited 1 time in total.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues with the upload/download code example

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

Re: Issues with the upload/download code example

Post 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!
Last edited by Chimar on Tue Sep 15, 2020 9:30 am, edited 1 time in total.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues with the upload/download code example

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

Re: Issues with the upload/download code example

Post 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!
Last edited by Chimar on Tue Sep 15, 2020 1:38 pm, edited 1 time in total.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issues with the upload/download code example

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

Re: Issues with the upload/download code example

Post by Chimar »

sure, will do!
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

Re: Issues with the upload/download code example

Post by Chimar »

sent it!
Chimar
Posts: 14
Joined: Tue Aug 11, 2020 3:47 pm

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

Post 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.
Post Reply