Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Content size in entry update isn't validated, and some questions

Discussion in 'Unity Cloud Content Delivery' started by Kamyker, Aug 25, 2020.

  1. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,092
    With generated c# api to updated single file I'm doing:
    Code (CSharp):
    1. await cdn.UpdateEntryAsync( bucketId, entryId, GetEntryUpdateFromString( fileContent) );
    2. await cdn.UploadContentAsync( bucketId, entryId, new FileParameter( stream ) );
    3. await cdn.CreateReleaseAsync( bucketId, new Release() );
    1. In UpdateEntryAsync I can set content_size to whatever I want. For example I can set it to 1 byte and then send 1kb using UploadContentAsync file fine. Unity dashboard shows that file is 1 byte but downloaded file is 1kb as expected.

    2. Anyway why we have to call 2 methods, couldn't UpdateEntry and UploadContent be merged together?

    3. Is there any way to updated a file without creating release? Let's say I have to update a file every few mins, creating releases all the time will make almost 10k of them in a month.

    4. What type of hash should be used for content_hash in UpdateEntry?
     
  2. timtunity3d

    timtunity3d

    Unity Technologies

    Joined:
    Oct 1, 2015
    Posts:
    132
    Hi,

    I'm currently working on cleaning up a lot of this stuff so changes to make this make more sense is coming soon.

    1. This will soon be validated. In the future to create a release all files will have to have content_size and content_hash fields that match the file that is actually stored.

    2. They potentially could, although we wanted flexibility in how we upload content. Separating the paths allow multiple entries to refer to the same content and only have to upload it once. It also lets us support the TUS (tus.io) resumable file protocol which is coming soon.

    3. Yes. Every time you update a file it creates a new version. You can use the unreleased state of the bucket which will always have your latest file updates.

    4. It's currently md5. We're working on adding support for more hash types.

    Let me know if you want more detail on any of this. I kept starting writing answers, and realizing I was over-answering the question.
     
  3. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,092
    Hi, thanks, all clear, well almost... How can I get unreleased content with Content Delivery Client API?
    Tried using

    but always get errors. Does it work for you?
     
  4. timtunity3d

    timtunity3d

    Unity Technologies

    Joined:
    Oct 1, 2015
    Posts:
    132
    So we expect that you would want to use the client API (https://content-api.cloud.unity3d.com/doc_client/) for retrieving the content. That doesn't require an API key and has caching and uses a CDN. We expect most people would want to use 'Get content by path'. So something like this:


    https://[projectid].client-api-test.unity3dusercontent.com/api/v1/buckets/{bucketid}/entry_by_path/content?path=GameData.dat


    That will just give you the latest content for that file path in your bucket. We call it unreleased, but it could also return content that is part of a release. It's just the latest data.

    We expect this to be used more in the development phase and then once you start moving to things like alphas, betas, etc the release system would be used.

    I'm also interested in what errors you're getting from the 'Get entry versions' route.
     
  5. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,092
    Interesting I was trying to use it before but was a bit impatient as it seems that returned content is cached for ~3 mins, tried cache busting by using random parameter like &z=324987 but that way I always get
    "invalid query parameter z"
    error.

    Well found another way of adding random amount of "&" at the end of url to workaround the cache. In Unity I have my own implementation of caching data anyway.

    So in the end I use something like
    https://[projectid].client-api-test.unity3dusercontent.com/api/v1/buckets/{bucketid}/entry_by_path/content?path=GameData.dat&&&&&&


    Nevermind, works fine, didn't notice that it's in management api not in client. For a second I thought to maybe get the newest version and use
    /buckets/{bucketid}/entries/{entryid}/versions/{versionid}/content/
    to retrieve unreleased content.