Search Unity

How to use addressables using custom http rest server

Discussion in 'Addressables' started by Jribs, Nov 8, 2019.

  1. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    154
    Hello, let me explain what I need.

    I have my assetbundles stored in a private S3 bucket. The only way items can be downloaded from this bucket is by having a URL for the item that has a temporary valid code as part of the URL.

    When we want to download an asset we hit the server telling it which items we need. The server then will generate those unique URLs that will give them access to the S3 bucket. Those URLs are sent back to the unity client and the items are downloaded using those URLs.

    I haven't been able to figure out if something like this is possible using the addressable system. The way I understand it is the remote path for the bundle is defined at build time, and then that is the path that is used to find the bundle. I guess if there was a way to change that at runtime per bundle that might work if that could also be applied to automatic dependencies.

    I need to be able to say "Load this scene" and have it get all the dependencies using the special S3 urls it gets from the server.

    Any tips or direction to look to figure this out?
     
    Lyrcaxis likes this.
  2. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    116
    @Jribs I am in the same boat with addressables and Azure private blob. It's not like AssetBundles where you grab the one file. It needs to access the hash and bundle file too. Did you ever figure this out?
     
  3. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    154
    @mrekuc the only thing I was able to do was have the server provide the base download url that pointed to the correct S3 bucket.

    So when our users login, our server sends back a base url like "s3://s3.my-bucket.com/" then the addressable system will use that as the base to get the assets.

    Let me know if you want more info and I can respond with a more in depth response.
     
  4. Lalitsharma81

    Lalitsharma81

    Joined:
    Jun 19, 2020
    Posts:
    13
    @Jribs I am kinda trapped in the same problem ... my bucket is private and i am generating pre-signed URLs which has expiry time directly pointing to the .bundle file and I access bundles via that ... but the one time init of addressables is posing me a huge problem ... so moved back to asset bundles downloading assets one by one ... if have any workaround for my issue please help.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Flagging this with the team to share some guidance.
     
    Lyrcaxis likes this.
  6. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    I'm not sure if this will help but we do have a settable Func on the Resource manager to modify urls before the web request gets created.

    Addressables.ResourceManager.InternalIdTransformFunc takes an IResourceLocation and returns a string (the new url) In the AssetBundleProvider we call var url = m_ProvideHandle.ResourceManager.TransformInternalId(loc); before creating the web request. I'd imagine you could use this to modify the url UnityWebRequest uses to be whatever you'd need.

    Let us know if that helps.
     
    Lyrcaxis and paulgullettMR like this.
  7. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    116
  8. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    116
    Thank you @davidla_unity & @TreyK-47

    I have verified that the above mothed worked for me keeping my assets private on Azure Blob Storage using a Shared Access Signature.
     
    Last edited: Feb 4, 2021
    TreyK-47 likes this.