Nerd For Tech
Published in

Nerd For Tech

Using AWS S3 with Unity

In my last article, I went over how I saved data for my app. With that data saved it is time to upload that data to Amazon Simple Storage Service (S3).

Before uploading the saved data you need to create a bucket that will hold the data and create permissions that will allow you to have access to all actions related to the bucket you created.

Go to the Amazon S3 Console. Click the create bucket button and follow the steps to create your bucket.

Go to the Identity and Access Management Console (IAM) and go to the Policies tab. Click the create policy button and set up the policy. The service will be S3 and you will select all for the actions and resources.

You will then go to the roles and click on the unauthorized role. You will click add policies under the add permissions drop-down bar.

Search for your policy and attach it.

Copy the ARN at the top of the screen for later.

Go back to the S3 console and select your bucket. Go to the permissions tab.

Scroll down to the bucket policy and select edit. This will take to a new screen that will have a button that says policy generator. Click this and create a policy. The policy will be your ARN that you copied down and the Amazon Resource Name will be in the format of arn:aws:s3:::bucketname/*.

Hit add statement and you will be able to generate a policy for it below.

Copy that policy and paste it into the policy on the screen you clicked the policy generator button on.

Now you are ready to go to unity and connect this with your project.

I have an empty game object that will be my AWS manager.

To initialize S3 I made a property that will return a variable that will be the initialized S3 client. You will need to go to Cognito to get your identity pool ID for your credentials.

You will need to use a couple of different namespaces for AWS to work.

In the awake method, you will need to add some code that will tell the program to use unity web request as the HTTP.

Now I created a method that will upload the saved data to S3. This method is outlined in the documentation that is available for AWS.

This method is called from the UIManager under the submit button I worked on in the last article.

I also created a method to look up a case number and download that data from S3. This method is also outlined in the documentation.

This method is called from the search panel.

This is how I set up S3 for my app.

Link to Documentation: https://docs.aws.amazon.com/mobile/sdkforunity/developerguide/s3.html

--

--

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