Data Communication with AWS: Part 2- App Dev Series 8

Objective: create a bucket of AWS S3 and linking to it with our app.

Photo by Lucas van Oort on Unsplash

We have finished the file sending request in the previous article.
Today we will focus on the setting of AWS S3.

S3 bucket

To start using S3 bucket, go to AWS console and search S3.

Select S3 to the page, and click Create Bucket on the top right.

Make a unique name to your bucket and adjust all the settings you need.

After these, you should have a bucket in your list.

Using S3

Now we need to start using S3 service. We will check the documents of AWS mobile SDK for Unity and follow the steps.
First we need to create a S3 client. Before we follow the steps of guiding documents, it would be better if we using all the namespace from the code example in AWSSDK folder, and paste it into the AWSManager script we created in the previous tutorial.

That way we could prevent any unexpected error in the upcoming setting.
After using all the namespace, we can follow the instruction of guiding documents to create a S3 client.

Copy and paste this line into Awake() method of AWSManager script.

After pasted it, there should be an error since we have not declare the variable yet. If we back to Set up AWS mobile SDK for Unity guiding documentation, there is an example code of using Cognito to obtain the key.

Copy and paste the example code to Awake() and above the line of S3Client.

Ensure and copy your identity pool ID and region, then cover the data of example code.

List buckets

Following the instruction of guiding documents, next should be list all buckets.

As the previous section, it is also contain an example code of this part.
Copy the code and paste it under creating S3Client line of code.

And as it mentioned in the comment, ResultText is using to display the status, which we will not use it in our code. Delete all the lines with ResultText, and change Client to S3Client.
Because we only got one bucket, we can change the line under the ForEach() method, and just reveal the name of our bucket by using Debug.Log.

Configure the RegionEndpoint

Before we run the app to test if we can receive our bucket name, there is a configuration of RegionEndpoint we need to do.
If you run the app in this way, you should receive the error message like me:

We need to configure the RegionEndpoint, which we can find the reference in the S3Sample script.
Open the script, and locate the RegionEndpoint variables at about line 39.

Copy this part into AWSManager and change the region to the region of your.

Then add the RegionEndpoint to S3Client as the parameter of new S3Client.

Using UnityWebRequest as HttpClient

There is one more adjustment it need to be done. After we run the app, it might shows the error called InvalidOperationalException.
We can fix the error by using the default UnityWebRequest as HttpClient to AWS.
Add one line to Awake() just after the UnityInitializer.

Now your app should run without any error.

That’s all for this article.
We will continue configuring the communication with S3 in the next article.




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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Best Front End Framework For Ruby On Rails App- Ember.JS Or AngularJS?

Lean Thinking and the Parable of the Underbrush

Why Every Junior Developer Needs A Senior Developer

iOS App Performance Tips

Best practices for designing a Rails app that connects to a 3rd party API?

Service Level Objectives for Engineering On-call Peace of Mind

3 Things I wish I knew as a Junior Engineer at Microsoft


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

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

More from Medium

How to setup Git for a Unity project

Deploy Application to Remote Docker Server (Without Kubernetes Cluster) with Gitlab CI/CD

Configure AWS Mobile SDK for Unity!

Git, Gitlab, Gitflow: Time and space travelling’s traffic laws