cancel
Showing results for 
Search instead for 
Did you mean: 

Oculus Quest2 - issue on writing files in sdcard/Download location.

cockcrow0412
Honored Guest

I have already got the permission for WRITE_EXTERNAL_STORAGE.

But DownloadHandlerFile of UnityWebRequest cannot create file in sdcard/Download location and always failed.

What is the cause?

Is there someone to resolve such issue?

 

3 REPLIES 3

Anonymous
Not applicable

cockcrow0412
Honored Guest

Thanks for your reply @Anonymous 

I have already referred and tried many similar cases, including the above URL.
However, it still does not work on Quest2.
It seems to work on other Android systems and Quest1 except Quest2.
Have you tried Quest2 yourself?
My app actually has the WRITE_EXTERNAL_STORAGE permission, but it is not creating a file.

Phluxm
Honored Guest

Are you using Unity? If so I got this working on the Quest 2. 

I downloaded the video to the persistent storage first, and then set the path (URL) using downloadHandler, finally set the URL to that location.

Put something like this in a Coroutine...

 

 

IEnumerator DownloadVideoFromURL()
{
    var webRequest = UnityWebRequest.Get(url); //Get the video file form URL
    string path = Path.Combine(Application.persistentDataPath, file_name + ".mp4"); //save it to the SDcard
    webRequest.downloadHandler = new DownloadHandlerFile(path);
    yield return webRequest.SendWebRequest(); //wait until web stuff finishes
    if (webRequest.result == UnityWebRequest.Result.Success)
    {
            videoPlayer.url = path; //when downloaded, set the URL of the VideoPlayer
            Debug.Log("File successfully downloaded and saved to " + path); 
            StartCoroutine(PlayVideo()); //start another coroutine to play the video or whatever
    }
}