Data Communication with AWS: Part 1- App Dev Series 7

S.J. Jason Liu
3 min readSep 9, 2021

Objective: serialize the data file into format that can be used to send it to AWS.

Photo by Markus Spiske on Unsplash

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.

System.Serializable is an example to serialize a data to editable content in Unity

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.

In here, we set the case id number as file name and dat format.

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.

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.