Amazon S3 for Asset Bundles

Can someone link a good thread covering this? If not can someone help out? Everything I found online is very outdated and/or broken. I even found forum threads that fixed the broken documentation but they were broken as well. I followed these steps:

  1. Original documentation (apparently broken)
    Set Up the AWS Mobile SDK for Unity - AWS Mobile SDK for Unity
  2. Fix for the documentation (also broken)
    How To Connect to S3 in Unity - What's in a Game?
Received error response: [<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>BBE04EE2D17B2FDB</RequestId><HostId>qmntxx9aAHb+uyAQ7S+u5fUWlgmQPX/AXm2TRFVwcKEWeTm4ZikkjE9Do5+hnRPZlC2IXB3M5yk=</HostId></Error>]
UnityEngine.Debug:LogError(Object)
Amazon.Runtime.Internal.Util.UnityDebugLogger:Error(Exception, String, Object[])
Amazon.Runtime.Internal.Util.Logger:Error(Exception, String, Object[])
Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler:HandleException(IExecutionContext, HttpErrorResponseException)
Amazon.Runtime.Internal.ExceptionHandler`1:Handle(IExecutionContext, Exception)
Amazon.Runtime.Internal.ErrorHandler:ProcessException(IExecutionContext, Exception)
Amazon.Runtime.Internal.ErrorHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.S3.Internal.AmazonS3ResponseHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.Unmarshaller:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.RedirectHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
Amazon.Runtime.Internal.HttpHandler`1:GetResponseCallbackHelper(Object)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()

Type the URL of your asset into a browser. Can you download it? I’m guessing not.

If not, then it’s nothing to do with Unity but rather with the URL or else the access rights.

If you can download it with a brower, then put the on your local system and serve it (like with NPM httpserver). Can you get it that way in Unity?

You are correct, I also get the access denied when I try to download it through my browser, however, that’s due to the bucket NOT being public. As far as I’m aware if you make a public bucket anyone can download your files (and when I do this, I can download the file through the browser without issues), which is something I would like to avoid. Amazon’s Mobile SDK for Unity should solve this issue. It should let me download non-public files from buckets but I have no idea if I’m missing something here.

Managed to solve it after a while, sorry for taking your time and thanks for your help.

Turns out I had to set permissions for the unauthenticated IAM roles. This is the JSON file that enabled reading for me:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "mobileanalytics:PutEvents",
                "cognito-sync:*",
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
1 Like