- Home /
What's the best way to save data to the cloud?
I want to save my game data to my server. I am using php /mySql but it seems that Unity has limitations in place when using the wwwForm method which prevents me from uploading more than 1000 fields.
Therefore, what's the best method for posting my save data online?
Answer by Soviut · Jun 23, 2012 at 11:44 PM
Serialize your data to either JSON or XML and then transfer that in a single "data" field in your POST request to the server.
Once you receive this payload on the server, you can either deserialize the data into database fields, or simply store the entire data object in a single text field. In both cases, you should maintain a unique ID as well as a datetime field for when the record was created.
Then, to fetch saved games, expose a URL on the server that takes an ID and return the saved data. Remember to set the correct MIME content type for JSON (application/json) or XML (application/xml) so that PHP and Apache don't try to inject any additional data into the header or body of the response.
For more complex interoperability with a server (user authentication, fetching data from several different tables, etc.) you should consider reading up on how to build REST APIs. These are the type of web services Twitter and Google use to allow 3rd parties access to their data.
Your answer
Follow this Question
Related Questions
Guardar playerprefs en un servidor 0 Answers
How to update game for happenings while player is away? 0 Answers
server based unity video capture 1 Answer
Save the inventory items to the database 0 Answers
Server-side generated heightmap 0 Answers