Data Communication with AWS: Part 1- App Dev Series 7
Objective: serialize the data file into format that can be used to send it to AWS.
In the upcoming articles, we would create a file from data inside the app, then make Unity communicate with AWS and allow us to upload or download the file from it as database, which is also a save/load function.
Concept
To run this part, we would need to serialize the data into some file format(ex. json), and upload it to AWS as saving.
When we need to load some process of our app or game, just download that file and de-serialize it back to data, so Unity would be able to read it.
Serialize file into binary format
In this article, I would do the example with a data called “case” to serialize.
To enable switching format from data to file, we need to use the specific library.
After using the library, create a binary format variable for a later use by using BinaryFormatter.
Once done, we need to use another library to enable the function of creating file.
Now we can use FileStream to set a file type with assigned format name, and a persistent directory to save that file.
Once finished setting the format and directory, use BinaryFormatter.Serialize() to make the “case” data into file.
After serialized, close the file to finish this process.
That’s all to create this serialization function.
It should create a file in your persistent data path folder when the method has been called.
Now we successfully create a file from the data, we would continue uploading this file and to AWS.