Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Amazon S3 for Asset Bundles

Discussion in 'Scripting' started by Dextozz, Oct 18, 2019.

  1. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    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)
    https://docs.aws.amazon.com/mobile/sdkforunity/developerguide/setup-unity.html
    2) Fix for the documentation (also broken)
    http://whats-in-a-game.com/how-to-connect-to-s3-in-unity/

    Code (CSharp):
    1. Received error response: [<?xml version="1.0" encoding="UTF-8"?>
    2. <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>BBE04EE2D17B2FDB</RequestId><HostId>qmntxx9aAHb+uyAQ7S+u5fUWlgmQPX/AXm2TRFVwcKEWeTm4ZikkjE9Do5+hnRPZlC2IXB3M5yk=</HostId></Error>]
    3. UnityEngine.Debug:LogError(Object)
    4. Amazon.Runtime.Internal.Util.UnityDebugLogger:Error(Exception, String, Object[])
    5. Amazon.Runtime.Internal.Util.Logger:Error(Exception, String, Object[])
    6. Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler:HandleException(IExecutionContext, HttpErrorResponseException)
    7. Amazon.Runtime.Internal.ExceptionHandler`1:Handle(IExecutionContext, Exception)
    8. Amazon.Runtime.Internal.ErrorHandler:ProcessException(IExecutionContext, Exception)
    9. Amazon.Runtime.Internal.ErrorHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    10. Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
    11. Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    12. Amazon.S3.Internal.AmazonS3ResponseHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    13. Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
    14. Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    15. Amazon.Runtime.Internal.Unmarshaller:InvokeAsyncCallback(IAsyncExecutionContext)
    16. Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
    17. Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    18. Amazon.Runtime.Internal.RedirectHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    19. Amazon.Runtime.Internal.PipelineHandler:AsyncCallback(IAsyncExecutionContext)
    20. Amazon.Runtime.Internal.PipelineHandler:InvokeAsyncCallback(IAsyncExecutionContext)
    21. Amazon.Runtime.Internal.HttpHandler`1:GetResponseCallbackHelper(Object)
    22. System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
    23.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,519
    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?
     
  3. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    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.
     
  4. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    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:

    Code (CSharp):
    1. {
    2.     "Version": "2012-10-17",
    3.     "Statement": [
    4.         {
    5.             "Effect": "Allow",
    6.             "Action": [
    7.                 "mobileanalytics:PutEvents",
    8.                 "cognito-sync:*",
    9.                 "s3:Get*",
    10.                 "s3:List*"
    11.             ],
    12.             "Resource": [
    13.                 "*"
    14.             ]
    15.         }
    16.     ]
    17. }
     
    Kurt-Dekker likes this.