Jump to content

Downloading files from external sources (over WiFi)


Recommended Posts

Ok
This won't work. I don't have a server running on that host PC, so http will not work.

So I tried to log the errors with logcat, here's what I got : 
Error downloading file: Could not find a part of the path "/SharedFolder/videoFile.mp4".
                 UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
                 UnityEngine.Logger:Log(LogType, Object)
                 UnityEngine.Debug:LogError(Object)
                 VideoDownloader:WebClient_DownloadFileCompleted(Object, AsyncCompletedEventArgs) (at D:\Unity Projects\2024_am_vr_immersive_multiplayer_atlantis\Assets\_\Scripts\MonoBehaviours\VideoDownloader.cs:80)
                 System.Net.WebClient:OnDownloadFileCompleted(AsyncCompletedEventArgs)
                 System.Net.WebClient:<StartAsyncOperation>b__78_4(Object)
                 UnityEngine.WorkRequest:Invoke() (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\UnitySynchronizationContext.cs:153)
                 UnityEngine.UnitySynchronizationContext:Exec() (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\UnitySynchronizationContext.cs:83)
                 UnityEngine.UnitySynchronizationContext:ExecuteTasks() (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\UnitySynchronizationContext

Doesn't help much, does it ? 
I don't understant why it didn't put the host name at the beginning of the path.

It was readable when I debugged in Unity before calling webClient.DownloadFileAsync(new Uri(url), localFilePath);
it was \\\\HostName\\SharedFolder\\videofile.mp4

 

Trying with other file type (txt), I'll let you know in a few minutes

Different file type, same error. 
It just seems it cannot access the files in that folder.

 

Link to comment
Share on other sites

I think I found the android manifest, 
I think I need an extra permission, it is not present in the manifest: 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

How do I add this ? it is rebuilt on every build.

Thanks ! 

Link to comment
Share on other sites

Did you find AndroidManifest.xml file under <project folder>\Assets\Plugins\Android\ path?

If you don't, you can try building your project and it will be automatically added, make a copy of it before it gets deleted after build completed.

Link to comment
Share on other sites

I'm not able to share the project at the moment, way too big and full of proprietary code 😞

I'm going to do a small version of it with only this code, I need to do it for testing anyway, and I'll share it on a new gitlab repository. 
I'll start with this tomorrow.

I deleted the AndroidManifest.xml in the Assets/Plugins/Android and it did not recreate on the next build. 

As far as I remember, it was never there in the first place. 
It only appeared yesterday when I tried to check the "custom main manifest" checkbox in Project Settings > Player > Publishing Settings.
So as I understand it it generates the AndroidManifest.xml on each build but I don't know where and how to update it manually.

So tomorrow around 10-11 CET I'll be able to share the project with you. 
I'm running this in unity 2022.3.15f1 so I'll send it to you this way. 

I'll send you a PM when it's ready.

Thanks a lot!

Julien

 

Link to comment
Share on other sites

22 minutes ago, JulienActiveMe said:

It only appeared yesterday when I tried to check the "custom main manifest" checkbox in Project Settings > Player > Publishing Settings.

I guess this step generate the AndroidManifest.xml.DISABLED file.

I will wait for your sample project, thanks!

Link to comment
Share on other sites

  • 2 weeks later...
Posted (edited)

Hi Julien,

I get what you're going through with trying to make your stuff work on the Focus 3. It can be a bit tricky sometimes!

So, about that error you're getting with WebClient.DownloadFilesAsync(), it might be because your device is having trouble finding the right place to put the file. Maybe it's something to do with how the paths are set up.

Oh, and when I was trying to figure out my own problems, I ran into this thing called FRP lock. It's like a security thing on your device that can sometimes mess with file stuff. Make sure your device is allowed to get files from where you're trying to get them.

Hope this helps you out!

Best,

Edited by AmberSHINA
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...