Search Unity

Question CLI upload directory counterpart for REST API

Discussion in 'Unity Cloud Content Delivery' started by Developer1999-1, Sep 15, 2022.

  1. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    38
    If we are using CDN CLI, there is an easy command line to upload the built Addressables by its output directory path, which is:

    ucd entries sync /path/to/built/addressables --environment <enviroment-id>

    However, looking through the API documentation, there doesn't seem to be a counterpart for doing the same thing, but only an API for uploading a single entry.

    Is there an easy to to upload the built Addressables by its output directory easily through API?

    Thank you!
     
  2. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    38
    Ended up writing a custom editor script to handle this problem. It's basically just a walk through of the directories and calling the API, which I think has always been the intended usage. However, I should mention that the examples of the API are outdated from the ones on the official API Documentation, as the examples are lacking the environmentid path.
     
    SebT_Unity likes this.
  3. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi Wiseye,
    Thanks for bringing this to our attention. When possible can you share the documentation you are referring to? I would like to make sure that it gets updated as soon as possible.

    Thank you
     
  4. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    38
    Hi, by examples, I mean the examples under "Upload content user API" in the Buckets Dashboard.
    upload_2022-9-19_13-43-13.png

    And by documentation, I mean this: https://content-api.cloud.unity3d.com/doc/
     
    SebT_Unity likes this.
  5. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Thanks Wiseye, Appreciate that information
    While we get that documentation updated you can refer to the following link for API.
     
  6. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
  7. Developer1999-1

    Developer1999-1

    Joined:
    Oct 27, 2020
    Posts:
    38
    Sorry for not being clear. What I mean is this:

    1. Log into Unity Dashboard > LiveOps
    upload_2022-9-21_20-46-12.png

    2. Select Buckets
    3. Enter one of the buckets
    4. Scroll to bottom
    5. There should be an example of using curl to use the API, which doesn't use the environmentid

    Also, can I know where the users are supposed to find this link you just posted? (https://content-api.cloud.unity3d.com/doc/cli-sync-api.html)? Because I looked through the website but never saw this explanation. If I had seen it, I would have a much better idea of how to use the API. For example, the content-hash I am calculating is using MD5, which is the intended way, but for me, it's just a random guess from the word "content-hash."

    Edit: I now see where the link is. However, I think these steps should just be...on the API documentation itself? For me, it was very to miss that single sentence of the hyperlink. I think for other users, it would be equally likely easy to miss as well.

    Edit 2: I think it's even better if you would provide a possible C# implementation of this. When I started, I attempted to use UnityWebRequest to send out the requests, which turns out to be very hard to use for setting all the headers and content. I later on switched to C#'s standard HttpClient to create a custom build pipeline, but it took a long to figure out.
     
    Last edited: Sep 22, 2022