Closed mattleibow closed 2 years ago
@Eilon I think whatever we do is going to affect Blazor. I think we need to get that #791 change in. Just looking at your issues, I see there are a few around this.
We probablu need somehting for Blazor (that can convert to a MauiAsset under the hood with special values), but right now we need something way better than what we have.
@mattleibow maybe we should have a chat about MauiAssets and whatever we'd like to change/improve there?
So... does anyone know a way to access assets? I would like to just point to a file on a known location and opening it, I think that should be common code.
Note: I'm using Blazor, I don't have experience with Xamarin but I have with UWP.
@IIARROWS I may be "doing it wrong" but for UWP, MauiAssets doesn't work. I have to use Content
type build action, then use Maui.Essentials.FileSystem.OpenAppPackageFileAsync
and a relative path to the file.
For Android, I must use MauiAsset
build action and the same package.
This seems broken to me.
Guess I was doing it wrong. With UWP, you should set your build action to MauiAsset
then:
await Microsoft.Maui.Essentials.FileSystem.OpenAppPackageFileAsync("Assets/{same path in app });
Better yet:
#if WINDOWS
var stream = await Microsoft.Maui.Essentials.FileSystem.OpenAppPackageFileAsync("Assets/" + filePath);
#elif ANDROID
var stream = await Microsoft.Maui.Essentials.FileSystem.OpenAppPackageFileAsync(filePath);
#endif
Hi folks, we definitely have some work to do to make consuming MauiAssets easier.
Here's the "rough" code that we have in BlazorWebView for each platform (Android, iOS/MacCatalyst, and WinUI):
But of course we should just make this a lot easier to use. But hopefully this unblocks people in the meantime.
Notes from meeting with @mattleibow :
Description
I added a
<MauiAsset Include="Resources\Assets\*">
in my project and I was unable to easily find how to retrieve it. I used Essentials'FileSystem.OpenAppPackageFileAsync
and I found that it went to different folders: