Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Possible to limit amount of content uploaded per user?

Discussion in 'Unity User-Generated Content' started by SorneBachse, Sep 30, 2023.

  1. SorneBachse

    SorneBachse

    Joined:
    Dec 27, 2012
    Posts:
    62
    Hi.

    Is it possible to somehow limit the amount of uploads a user can do, server-side? Say, each user can upload 10 levels/content maximum. And then they can delete their existing content if they wish to free up more space.
    This can of course be handled client side no problem, but I also want to perhaps return 400 Bad Request from the server if they've reached their max limit.

    Can this be done via WebHooks? Or do I need to write my own API around it?

    Cheers.
     
  2. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    173
    Hi @SorneBachse,
    You can use the search player content which returns the content count and add filters as you see fit.
    There is also an obsolete variable still usable: PlayerContentCount

    But it's up to you to develop how you want to manage this.
    Let me know if you have questions.
     
    zjebali likes this.
  3. SorneBachse

    SorneBachse

    Joined:
    Dec 27, 2012
    Posts:
    62
    Oooh neat! So I'll be able to query the backend before uploading to check if the player has reached the maximum amount of uploads? Great, that's just what I need, thanks !

    EDIT:
    In case anyone else was wondering, the endpoint returns ALL content ever uploaded by the player including deleted content. In order to only get all the non-deleted content you can add the following filter:
    Code (CSharp):
    1. var result = await UgcService.Instance.GetPlayerContentsAsync(new GetPlayerContentsArgs
    2. {
    3.      IncludeTotal = true,
    4.      Filters = new List<string>
    5.      {
    6.           // syntax: {field},{operator},{value}
    7.           // source: https://services.docs.unity.com/user-generated-content-client/v1/#tag/Content/operation/SearchPlayerContent
    8.           "deletedAt,eq,null",
    9.      },
    10.  });
     
    Last edited: Oct 3, 2023
    Arnaud_Gorain likes this.