Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Hosting WebGL build files (data, code, mem files) on Amazon S3

Discussion in 'WebGL' started by edgar_abadines, Apr 22, 2016.

  1. edgar_abadines

    edgar_abadines

    Joined:
    Mar 30, 2016
    Posts:
    4
    Does anyone use Amazon S3 for this purpose? I have a Rails application with my own index.html (taken from the WebGL build). I have gotten to the point where I've:

    1. Changed dataUrl, codeUrl, memUrl to their respective: "https://s3.amazonaws.com/<bucket>/Release/MyApp.data", "https://s3.amazonaws.com/<bucket>/Release/MyApp.js", "https://s3.amazonaws.com/<bucket>/Release/MyApp.mem".
    2. I've changed the CORS to the following:
    <CORSConfiguration>
    <CORSRule>
    <AllowedOrigin>http://*</AllowedOrigin>
    <AllowedOrigin>https://*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
    </CORSRule>
    </CORSConfiguration>
    3. Added the following metadata for each of the files MyApp.datagz, MyApp.jsgz, MyApp.memgz: Content-Encoding: application/x-gzip

    After all the above, I get the following browser errors when I try to bring up my Rails page:
    [Log] Invoking error handler due to (UnityLoader.js, line 1)
    SyntaxError: Invalid character '\u0031'
    [Error] SyntaxError: Invalid character '\u0031'
    (anonymous function) (blob:https://talking.herokuapp.com/e02e2cfa-bee0-403a-8d8d-11a6031d6fc1:1)
    [Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (MyApp.mem, line 0)
    [Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (MyApp.data, line 0)
    [Log] Decompressed https://s3.amazonaws.com/MyApp/Release/MyApp.memgz in 42ms. You can remove this delay if you configure your web server to host files using gzip compression. (UnityLoader.js, line 1)
    [Log] Decompressed https://s3.amazonaws.com/MyApp/Release/MyApp.datagz in 1710ms. You can remove this delay if you configure your web server to host files using gzip compression. (UnityLoader.js, line 1)


    Anyone know what I'm doing wrong? FYI, I've replaced the actual buckets above with MyApp.
     
    Last edited: Apr 22, 2016
  2. edgar_abadines

    edgar_abadines

    Joined:
    Mar 30, 2016
    Posts:
    4
    Figured it out. Removing the Content-Encoding metadata seems to have taken care of the page loading. I'm still seeing some errors about not being able to load the MyApp.js file due to 403 but it seems to continue to load and run now.
     
  3. pchuri

    pchuri

    Joined:
    Aug 18, 2014
    Posts:
    12
    Did you try to Rename all *.*gz files to drop the gz extension? (eg: MyApp.datagz renamed to MyApp.data)