Jump to content

Downloading files from external sources (over WiFi)


Recommended Posts

Hello,
I'm trying to download a file from a PC to the Focus 3, over WiFi.
I'm using Unity Netcode to connect to the server running on a pc. 
Upon connecting to the server, I try to detect the presence of a video in the Android/Data/com.CompanyName.ProductName/Files folder.
The video is too big to be added in the build, and I'd like to be able to update/change this video if needed without changing the build.

If not present (or need to be updated), I try to download it from a shared folder on the pc running the server. 

I'm using WebClient.DownloadFilesAsync() to do this.
It's not working as intended. I get the following error :
Could not find part of the path: {Path to file}.
I did a pc build, ran it on another PC connected to the same WiFi network, and it worked flawlessly.

I'm wondering if I missed an option in the batch config or in unity for it to work on my HMD. 
Or even if WebClient is the way to go here.

Any help would be greatly appreciated!

Thanks, 

Julien 

Link to comment
Share on other sites

Hi @JulienActiveMe,

To clarify if I understand your questions,

You have a content running on Focus 3 and it will download video file from your PC if it is not present in android/data/com.CompanyName.ProductName/files.

Is this correct?

Did your content added storage permission?

Link to comment
Share on other sites

Yes this is correct.
What do you mean if my content added storage permissions ? 
For now, I add this video manually after pushing the new build, either over ADB or by connecting the HMD to the pc with usb c and accessing the file storage of the HMD. 
If present, the video loads and plays just fine when it needs to, so my app is allowed to read internal content. 
It is also able to write content, because even if the download failed, it created the file where it is supposed to go (but it has 0kb). 
Maybe it is not allowed to read external content ? 
I'm trying to look for that option in the unity project settings > player but I don't seem to find it. 
I have a "Allow downloads over http" but it is set to "Always allowed".

Thanks in advance! 


 

Link to comment
Share on other sites

Actually what I was thinking is your content running on Focus 3 should be the one downloading content from your PC.

Then your content will need to have permission to write to disk while downloading files over Wifi.

Or maybe I am wrong?

Could you collect log for further investigation?

"adb logcat > filename" collect before you launch your content and until you download file from PC and it has 0kb? 

Link to comment
Share on other sites

It says access is denied

Now I tried something else.
Instead of forming my url like this : 
\\{HostPCName}\SharedFolder I tried forming it like this : 
string url = $"http://{serverIPAddress}/SharedFolder/{fileName}.{extension}";

Now I do not have this error anymore, but it does not download.
It's stuck at 0% (I have a callback for webClient.DownloadProgressChanged that updates my GUI to be notified of progression. It is working fine on the PC build).

Link to comment
Share on other sites

OK So I re-read your answer. 
The content on the HMD is the one downloading the content on my pc. 
The content has permission to write to disk.
It just seems that it cannot read the file on the pc.
 

Link to comment
Share on other sites

How did you setup the file sharing system on your PC?
- I gave access to everyone, but there are credentials that I am specifying in the code before attempting to DL the file.
Not sure if it is because of firewall that blocks you from downloading?

- Firewall is deactivated for now.

As I said in the original post, this is working just fine when I build the app for pc and try it on another pc, connected to the same Wifi.
It just seems like the HMD for some reason does not have access to or cannot read this file. 
 

Link to comment
Share on other sites

Ok When I tried this string url = $"http://{serverIPAddress}/SharedFolder/{fileName}.{extension}";
I had a url malform. 
Now the url is formed correctly, I have another error. 
ConnectFailure (mono-io-layer-error(111))
I'm trying with a different file type and I'll let you know.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...