Open TheSpydog opened 4 years ago
Thanks for the report!
Files are a tricky topic. Content files are part of the website payload, but are not populated as part of the emscripten VFS. You'll need to download the file from the payload first. The files are located in the package_XXX folder, that you can get from the UNO_BOOTSTRAP_APP_BASE
environment variable.
The bootstrapper itself does not provide any helper to get the file from the payload, aside from using the out-of-the-box .NET HttpClient
to get the file.
Ah, okay. Is there a particular reason Uno doesn't populate files into the VFS? I noticed that mono-wasm's packager tool supports preloading so I'm just curious.
It's something we have not needed at this point, but we contemplating adding a specific metadata to flag (e.g. <Content Include="MyFile.txt" Prefetch="embed|prefetch" />
to enable that scenario.
In the larger Uno Platform project that uses the bootstrapper, we're going to avoid this difficult (and pretty much static) choice by wrapping the usage of Windows.Storage.StorageFile
to automatically download files from the payload as needed using the ms-appx://
scheme, in async manner.
we contemplating adding a specific metadata to flag (e.g.
<Content Include="MyFile.txt" Prefetch="embed|prefetch" />
to enable that scenario
That would be very helpful. I found a workaround to enable preloading by manually passing --preload-file /mnt/c/path-to-file/<filename>@<filename>
in the WasmShellExtraEmccFlags part of the csproj, but obviously that's cumbersome and not ideal.
When I add a content file to my project and attempt to access it at runtime, I get a
System.IO.FileNotFoundException
. Here's a simple example:The csproj:
The "mytext.txt" file is in the same directory as the .csproj. When building and running this project with FullAOT, I see this in the browser console:
I'm not sure if this is a bug in Uno or if I'm just doing something wrong. From the README it seems like simply adding this Content property to the file is sufficient for Uno to include it in the virtual file system, but maybe not? Or maybe it's in a different directory? Any advice would be appreciated.