How to upload videos with Unity UGC

For our current project we were using the Cloud Save feature of Unity to save videos that the user makes, but then we discovered that it only allows 1 Gb per user. Unity itself said that if we wanted to allow users to upload a bigger amount of data we should use the UGC functionality.

Our problem is that once uploaded, the dashboard always says the same about the video file when you try to access it to download it: “Something went wrong. We weren’t able to retrieve the resource you requested. Make sure the URL you provided is correct, and that your internet connection is OK.”

What’s strange is that we basically used the functions provided in the getting started page, which is the same we did when we were trying Cloud Save(and it actually worked there).

This is basicallly the code used when testing the functionality:

using System.Threading.Tasks;
using Unity.Services.Ugc;
public class UnityCloudConnection : MonoBehaviour
{
private async void Awake()
{
    await UnityServices.InitializeAsync();
}

private async void Start()
{
    await SignInAnonymouslyAsync();
    await CreateNewContentAsync(VideoPath); // Replacing VideoPath for the path of the video
}

public async Task SignInAnonymouslyAsync()
{
    Debug.Log("Executing sign in");
    try
    {
        await AuthenticationService.Instance.SignInAnonymouslyAsync();
        Debug.Log("Sign in anonymously succeeded!");
        Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}");
    }
    catch (AuthenticationException ex)
    {
        Debug.LogException(ex);
    }
    catch (RequestFailedException ex)
    {
        Debug.LogException(ex);
    }
}

public async Task<Content> CreateNewContentAsync(string filePath)
{
    using var contentStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
    var content = await UgcService.Instance.CreateContentAsync(new CreateContentArgs("VideoTest", "A description", contentStream) { IsPublic = true, TagsId = null/*, Thumbnail = thumbnailStream */});
    Debug.Log($"Created content with id: {content.Id}.");
    return content;
}
}

This succesfully uploads the video to the dashboard, but gives us the error.
The getting started page is this

*EDIT:
After putting the video file into a rar file and uploading that instead, the error still happened, so I guess It’s something to do with how the file is uploaded (or just an actual error in Unity Servers)

FIXED: After following the CodeMonkey tutorial, I discovered it was nothing to do with the file type, you just need to enable site visibility in the Web Portal Setup, then you can open the files.

Please keep in mind that ANY async service call can fail and will then throw an exception. Enclosing all service calls in try/catch and handling exceptions appropriately (eg abort, try again, inform user) is required if you don’t want the end user experience to be riddled with issues and crashes!