03-08-2021 07:53 PM
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?
03-09-2021 06:46 AM
Hi @cockcrow0412
Check my previous answers
https://forums.oculusvr.com/t5/Oculus-Quest-Development/Accessing-local-files/m-p/781254#M1334
Hope this helps.
03-09-2021 03:43 PM - edited 03-09-2021 04:29 PM
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.
04-05-2021 11:55 AM - edited 04-05-2021 11:59 AM
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
}
}