questions about saving to web

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

questions about saving to web

Post by trendtimer »

Hello, I have the php/mysql setup correct, but exactly how this works is a little unclear.

The upload example (from the "saving-and-loading-from-web guild) shows a URL creation like this.
myURL += "?webfilename=myFile.txt&webusername=user&webpassword=pass";

But it's not clear what the purpose of myFile.txt is. There's no mention of what this is used for. If the uploaded data gets store in mySql, why the .txt file?

Here's what I'm looking to do:
I already have a save script in place that I use to save my scene locally. These scripts save all the gameobject transforms, material choices, attacked script states etc.
I need to now make the exact same thing get saved on the server. Since I already have this save file created, can I make a single ES2.php call to save this on the server? How would I do this?

The upload example does this:
web.Upload(mesh)

And it's not clear to me what other types of parameters can be passed. Can I pass in file that was saved locally? An example would be helpful because I don't even see how to instantiate a "File" object in C# (I'm more experienced with Java), so am not even sure what I would pass into the upload method. Let me know, thanks!
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

It occurred to me that I could read my entire save file into a string, and then use the web upload method to upload it. But I have a feeling this may be the wrong way to go about this.
I'm probably being dense here, but a little guidance would be helpful. thanks.
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

I changed to using web.UploadFile which is what I needed. So you can ignore this question. thanks.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: questions about saving to web

Post by Joel »

Hi there,

Glad you found the UploadFile method. Let me clarify regarding the webFilename parameter.

The webFilename is used to group tags in the same way as a file would locally. For example, you can download all tags with a given webFilename by specifying the webFilename parameter when you download, and leaving the tag parameter out entirely.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

thanks. I did figure that out eventually.
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

But I do have another question. I see the DownloadFilenames() which is sort of what I need. But is there any way to do a LIKE filter on the query so that only certain names are returned?
My users will save game to the server with a unique identifier in the name and I want to retrieve the list of all their saved games. I'm sure I can figure out how to do this, but it seems like the kind of thing a lot of people might want, so I thought I'd ask.
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

I tried adding "&filefilter=myfilefiler" to the URL, and was going to check for this within ES2.php, but am getting an unknown parameter error. Am I correct to assume that this check is within ES2.dll?

If so then perhaps doing what I want might be more difficult that I expected. You should allow us to pass custom URL parameters in the URL so that we can modify ES2.php to meet our custom needs. What do you think?
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

Looks like someone asked the exact same question:

http://www.moodkie.com/forum/viewtopic. ... .php#p1320

I'll try using your advice. thanks!
trendtimer
Posts: 21
Joined: Wed Jun 08, 2016 9:31 pm

Re: questions about saving to web

Post by trendtimer »

For anyone interested, this works. You'll need to google for the CalculateMD5Hash method.

C# method

Code: Select all

 public IEnumerator LogFilenames() {
        Debug.Log("in LogFileNames");
        WWWForm form = new WWWForm();
        // This data will be sent to our PHP script via POST. 
        form.AddField("username", "yourusername");
        form.AddField("password", CalculateMD5Hash("yourpassword").ToLower());
        form.AddField("mode", "getfilenames");
        form.AddField("filefilter", "png");
        WWW web = new WWW("http://www.yourhost.com/ES2.php", form);
        yield return web;
        // Handle any errors that might occur.
        if (web.error != null) {
            Debug.LogError("An error occurred when trying to upload the data.");
        }
        // Now get the output.
        string output = web.text;
        Debug.Log("output=" + output);
    }

Change to ES2.php

Code: Select all

else if($_POST["mode"] == "getfilenames")
{
	$filefilter=$_POST["filefilter"];
	$getFilenamesStatement = $mysqli -> prepare("SELECT $fileFieldName FROM $fileTableName where $fileFieldName LIKE '%".$filefilter."%' ");
	$getFilenamesStatement -> execute();
	$getFilenamesStatement -> bind_result($data);
	while($getFilenamesStatement->fetch())
		//echo $data."\n";
	 echo $data.",";
	
	$getFilenamesStatement->close();
}
	// Close our connection.
	$mysqli -> close();

?>

User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: questions about saving to web

Post by Joel »

Hi there,

Glad you managed to find a solution to your problem!

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