Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
cockcrow0412's avatar
cockcrow0412
Honored Guest
4 years ago

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

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

Replies have been turned off for this discussion
  • 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.

  • 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
        }
    }