Upload your local directory/mutiple files created from Unity to Amazon S3 bucket via its high-level API UtilityTransfer.
Pardon my coding style and let's get our hands dirty.
-
- Log in to the Amazon Cognito Console and click Create new identity pool.
- Enter a name for your Identity Pool and check the checkbox to enable access to unauthenticated identities. Click Create Pool to create your identity pool.
- Click Allow to create the two default roles associated with your identity pool–one for unauthenticated users and one for authenticated users. These default roles provide your identity pool access to Cognito Sync and Mobile Analytics. Then you shall get the
CognitoIdentity
and theCognito Region
:
CognitoAWSCredentials credentials = new CognitoAWSCredentials (
"IDENTITY_POOL_ID", // Identity Pool ID
RegionEndpoint.USEast1 // Region
);
-
For Amazon S3(simple storage service) set up, please refer to Getting started with Amazon S3
-
Last step you should set Cognito identity pool to access Amazon S3:
Identity and Access Management Console
--> clickRoles
in the left-hand pane --> Type your identity pool name into the search box --> Two roles will be listed: one forunauthenticated users
and one forauthenticated users
--> Click the role for unauthenticated users --> SelectAmazonS3FullAcess
--> ClickAttach Policy
. The settings shown below will give your identity pool full to access to all actions for the specified bucket.
-
-
The release in this repo contains all the necessary AWS.SDK dependencies, including AWS SDK for .NET.45 and additional DLLs specifed in AWS Unity Support, so just download the release and install it in your Unity Assets.
-
Input four parametes of yours in the Unity inspector window. Click
Run
and pressSpace
button should upload the time stamp files generated in the application directory to the S3 bucket, and it's done.
-
-
-
Here I use the aws-sdk-net45 as the AWSSDK core rather than the Standard 2.0 as the official document recommends, because I found the Standard 2.0 would not work in both Unity standard 2.0 and .Net 4.X envs, while the aws-sdk-net45 works well on both envs.
-
The original script uploading object to S3 is written by @John Pignata in his repo aws-samples/aws-sdk-unity-samples, but this example only contains low-level API that you must specify the file's name when you upload, besides, the compatility is not ideal for some API is not supported like UtilityTransfer.
-