Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Not allowed to load local resource for Android #2907

Closed
tabachuk opened this issue Oct 11, 2021 · 13 comments
Closed

[Bug] Not allowed to load local resource for Android #2907

tabachuk opened this issue Oct 11, 2021 · 13 comments
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 s/duplicate 2️⃣ This issue or pull request already exists s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Milestone

Comments

@tabachuk
Copy link

I'm trying to set an Android local resource as an image source in Html, but I get this error in console:

image

Could you please explain me what I need to do to resolve this? I'm using MAUI Preview 8 with Blazor.

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android 🤖 labels Oct 11, 2021
@jsuarezruiz jsuarezruiz added this to New in Triage via automation Oct 22, 2021
@mattleibow mattleibow added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Nov 12, 2021
@mattleibow
Copy link
Member

This looks like Blazor? @Eilon is this maybe just the path is not valid? Usually the path is like sdcard/0/emulated/data or something...

@Eilon
Copy link
Member

Eilon commented Nov 12, 2021

Does Android allow directly displaying storage resources in the WKWebView? I thought it had to be in Android Assets? I wonder if this works in a regular WebView. We might be accidentally blocking this.

@tabachuk can you share more info about your code, such as how you are creating the WebView, and what the HTML source looks like?

@tabachuk
Copy link
Author

tabachuk commented Nov 12, 2021

@Eilon do you mean MAUI Blazor? I followed this repo.
All code concerned with MAUI Blazor configuration I copied from it.

@Eilon
Copy link
Member

Eilon commented Nov 12, 2021

@tabachuk got it thank you. Then you added something like <img src="file:///sdcard/0.jpg" /> to one of the .razor files? Can you show the exact HTML that you added?

@tabachuk
Copy link
Author

@Eilon yes. Here is the instance of HTML code:
<img id="cropImage" src="@(ViewModel.Photo.Source)" />
Where ViewModel.Photo.Source is the file path to an image, which I get from camera or gallery. I also tried to use file:///sdcard/0.jpg instead, but it still doesn't work. Exactly the same code I used in Blazor Mobile Bindings and it worked both on simulators and real devices. At one moment it stopped to work on my phone, but I didn't dig into this problem.

@Eilon
Copy link
Member

Eilon commented Nov 12, 2021

@tabachuk great thank you for the details. We might be accidentally blocking certain web requests, so I'll investigate this.

@maptz
Copy link

maptz commented Nov 15, 2021

Hi, I'm seeing this problem on Windows too using MAUI Blazor.

An image tag with an src that points to a file:/// does not load with the "Not allowed to load local resource" error.

Would be great to know a workaround for this? For e.g. is there a way of creating routing a server request in MAUI Blazor, ie use an HTTP client to call some local route which serves up raw image bytes?

@shimingsg shimingsg added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Mar 2, 2022
@shimingsg
Copy link
Collaborator

verified repro with VS 17.2.0 Preview 2.0 [32228.609.main] on Windows
image

@vhj1995
Copy link

vhj1995 commented Mar 3, 2022

verified repro with VS 17.2.0 Preview 2.0 [32228.609.main] on Windows image

Hi, I am Glad you verified it. I too hit the same thing. Any idea on when a fix would publish?

@mkArtakMSFT mkArtakMSFT added this to the Future milestone Mar 21, 2022
@ghost
Copy link

ghost commented Mar 21, 2022

We've moved this issue to the Future milestone. This means that it is not going to be worked on for the coming release. We will reassess the issue following the current release and consider this item at that time.

@vhj1995
Copy link

vhj1995 commented Mar 23, 2022

@mkArtakMSFT

Thank you.

When will next release be published?

How frequently are new releases is published in general? I need to have some expectations in terms of when apps can use local resources, in particular saving to local disk.

We've moved this issue to the Future milestone. This means that it is not going to be worked on for the coming release. We will reassess the issue following the current release and consider this item at that time.

@Eilon
Copy link
Member

Eilon commented Mar 23, 2022

@vhj1995 it means that it won't be fixed for the first release of MAUI, which is in Q2 of this year. The next version after that is I think not finalized, but probably at the end of this year (Q4).

@mkArtakMSFT
Copy link
Member

This issue will be resolved as part of dotnet/aspnetcore#30290

Triage automation moved this from New to Done Apr 20, 2022
@mkArtakMSFT mkArtakMSFT added the s/duplicate 2️⃣ This issue or pull request already exists label Apr 20, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/android 🤖 s/duplicate 2️⃣ This issue or pull request already exists s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

8 participants