Error while copying files from OBB to persistentDataPath (Quest 2)

I’m building an .apk for the Quest 2 and need to be able to copy two large video files to the persistentDataFolder. The video files are stored in an OBB file.

I have tried using ‘UnityWebRequest’ but are yet without any luck.

using UnityEngine;
using UnityEngine.Networking;
using System.IO;

public class CopyFilesFromOBB : MonoBehaviour
{
    private string[] videoFiles = { "vid1.mkv", "vid2.mkv" };

    IEnumerator Start()
    {
        foreach (string videoFile in videoFiles)
        {
            string sourcePath = Path.Combine(Application.streamingAssetsPath, videoFile);
            string localPath = Path.Combine(Application.persistentDataPath, videoFile);

            if (!File.Exists(localPath))
            {
                if (sourcePath.Contains("://") || sourcePath.Contains(":///"))
                {
                    // Load file from OBB using UnityWebRequest
                    UnityWebRequest www = UnityWebRequest.Get(sourcePath);
                    yield return www.SendWebRequest();

                    if (www.result == UnityWebRequest.Result.Success)
                    {
                        // Save file to persistent data path
                        File.WriteAllBytes(localPath, www.downloadHandler.data);
                        Debug.Log(videoFile + " is copied");
                    }
                    else
                    {
                        Debug.LogError("Failed to load " + videoFile + " from OBB: " + www.error);
                    }
                }
                else
                {
                    Debug.LogError("Invalid OBB file path: " + sourcePath);
                }
            }
            else
            {
                Debug.Log(videoFile + " already exists in the persistent data path");
            }
        }
    }
}

This produces the following error log:

05-24 17:45:56.175  5788  5812 E Unity   : Failed to load vid1mkv from OBB: Cannot connect to destination host 
05-24 17:45:56.175  5788  5812 E Unity   : d:MoveNext() 
05-24 17:45:56.175  5788  5812 E Unity   : UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
05-24 17:45:56.175  5788  5812 E Unity   :
05-24 17:45:56.177  5788  5812 E Unity   : Failed to load vid2.mkv from OBB: Cannot connect to destination host
05-24 17:45:56.177  5788  5812 E Unity   : d:MoveNext()
05-24 17:45:56.177  5788  5812 E Unity   : UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Have been struggling with this for a few days now, looking for answers online, tried several different methods, every single one leading to errors or causing the entire build to crash. I’m certain that the path for the OBB file is correct since I’m able to access other assets from it.

Would really appreciate some assistance here - thanks in advance.

I stubbled upon this script and actually manged to get the copying working with small video file (15 mb):

void Update()
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            if (Application.dataPath.Contains(".obb") && !obbisok)
            {
                StartCoroutine(CheckSetUp());
                obbisok = true;
            }
        }
    }

    public IEnumerator CheckSetUp()
    {
        //Check and install!
        for (int i = 0; i < paths.Length; ++i)
        {
            yield return StartCoroutine(PullStreamingAssetFromObb(paths*));*

}
}

public IEnumerator PullStreamingAssetFromObb(string sapath)
{
string filePath = Application.persistentDataPath + sapath;

if (!File.Exists(filePath) || replacefiles)
{
UnityWebRequest unpackerWebRequest = UnityWebRequest.Get(Path.Combine(Application.streamingAssetsPath, sapath));
var requestOperation = unpackerWebRequest.SendWebRequest();

while (!requestOperation.isDone)
{
yield return null;
}

if (unpackerWebRequest.result != UnityWebRequest.Result.Success)
{
Debug.Log(“Error unpacking:” + unpackerWebRequest.error + " path: " + unpackerWebRequest.url);
yield break; // Skip it
}
else
{
Debug.Log(“Extracting " + sapath + " to Persistent Data”);

if (!Directory.Exists(Path.GetDirectoryName(filePath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
}

File.WriteAllBytes(filePath, unpackerWebRequest.downloadHandler.data);
// Could add to some kind of uninstall list?
}
}
yield return null;
}
However, the application still collapses when I try to copy one of the large video files (2 GB), and I expect that process perhaps overflows the RAM.
Is there a workaround for this?