Today we need to upload the data directly to the AWS server. To do this we must first prepare the environment and finally through the code go to test and verify that the upload of files is correct.

AWS Management Console

Let’s start right away with AWS, as the first thing we need is to log in to our account and access the management console.

Here we will have several choices, the one that interests us is the creation of an S3 bucket. Click on it and go to create a new bucket.

We assign a name, set the region, and go on with the settings.

At the following entries, you don’t need to change the default parameters. Go to the bottom of the page with the “Create bucket” button

Now we need to go back to the console to go to Identity and Access Management (IAM).
We need to create a policy for our S3 service and allow certain actions. From the menu on the left, we select the policy item and go to create a new one.

We should fill in the requirements of the first panel. We select the service, enable all S3 action and select all resources. And let’s proceed.

Ignore the tags, go to the next window, give a name to your policy and click on create policy

Go back to the IAM window, select Roles, select an unauthenticated role.
On the summary page, you have to go and select the policy you created previously, clicking on the “attach policies” button.

We are at the final steps, on AWS, now we need to generate a bucket policy. Let’s go back to the S3 panel and select our bucket, move to “Permission” tab

We need to use a tool provided by the platform to generate a policy.

Clicking on Policy generator you will be on a new page, where you should choose the service and fill in all other fields.

in the principal field, you have to insert the Role ARN,

in the ARN field, you have to insert “arn:aws:s3:::YourBucketName/*”.
In my case, it is called app-service-bucket so it will be: arn:aws:s3:::app-service-bucket/*

Click on Add Statement and then on Generate Policy, you will get back a JSON file to copy in the policy field of the S3>Permission page.

Unity: AWSManager

Let’s move on to Unity, I had already explained previously the import of the S3 package for Unity and how to create an AWSManager inside the scene.

To realize this script I used the example that AWS offers us in its package and the documentation that can be found at this link.

First of all, we need to add some libraries that will be more useful as we go on with the process.

The second thing is to use the singleton pattern for our manager, we will need it to be able to call it directly.

The variables that we are using are part of the Amazon namespace and are used to connect to the client and to define the region of our server, so we must be sure that they match the ones we find on the AWS console page.

How to declare these two variables you will find directly in the documentation. This is my script:

In the Awake() method we are going to initialize everything we need, and we can check a first test of the connection.

If the test is successful you’ll see it directly from the Unity console.

Let’s move on to loading an image on our bucket, this will be the method that we’ll call up in the final Overview screen of our app when we insert a new case.

Now we’ve also managed to load the data, all that’s left is to figure out how to do the reverse proceeding and figure out how to load a case from our S3 bucket.

project manager by day, unity developer by night