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
Not allowed to load local resource #183
Comments
Got this same issue on android did you resolve it? |
I only got this issue when using ionics latest webview which also causes issues with other plugins. I rolled back the webview and its working now. |
How do you do that ? |
Having the same issue over here on a Android device (on browser works fine) |
setting the return type to base64 works!
it's not the best solution, but... |
@mateusknob can this option be globaly configure ? |
@macklus yes, check this section: https://github.com/zyra/ionic-image-loader#global-configuration |
You need to perform 2 actions to resolve.
Then
Ionic info
Ref: Documents : |
@mateusknob - your solution worked with an extra research and more steps implemented as above, thanks! |
Can confirm. You can follow the issue I opened there: I downgraded back to cordova-plugin-ionic-webview@1.2.1 and all works grate. Steps:
By the way |
just for confirm, solution of @mateusknob is working ?? |
Hi @macklus |
@Shtibel sadly, its not working for me. |
Hi, |
Where should I use it? |
Hi @SmirnovM91, Cordova and Capacitor apps are hosted on a local HTTP server and are served with the http:// protocol. Some plugins, however, attempt to access device files via the file:// protocol. To avoid difficulties between http:// and file://, paths to device files must be rewritten to use the local HTTP server. For example, file:///path/to/device/file must be rewritten as http://://path/to/device/file before being rendered in the app. For Cordova apps, the Ionic Web View plugin provides a utility function for converting File URIs: window.Ionic.WebView.convertFileSrc(). There is also a corresponding Ionic Native plugin: @ionic-native/ionic-webview. Please check this below link |
Is this still an issue with the latest releasE? |
Yes, it is. I traced it down to the |
There it is ☝️ |
@Shtibel Thank you very much! The new ionic webview plugin is the cause for the problem. |
Yes, I had found another solution. in .html in .ts getTrustImg(imageSrc){ |
This is the version where it works for me on https://github.com/ionic-team/cordova-plugin-ionic-webview/releases/tag/v1.2.1 |
import { normalizeURL } from 'ionic-angular'; |
Hi! After a update the cordova-plugin-ionic-webview to 2.x , the image stopped to load, but no errors throws. Any idea? |
after i using |
What is your local file path? |
You can try to upgrade to 3.x version, and call the "convertFileSrc" function. |
Use this and be happy. Do not downgrade as proposed by @Shtibel anymore, there's already a solution: ionic cordova plugin add cordova-plugin-ionic-webview
npm install --save @ionic-native/ionic-webview@beta import { WebView } from '@ionic-native/ionic-webview/ngx';
constructor(private webview: WebView) { }
...
img = this.webview.convertFileSrc('file:///Users/dan/camera-image-12345.png') Note 1: do not forget to register ❤️ |
@giovannipds Your solution will not work with the Ionic 3 app since it requires ionic native 5+ with Angular 7+. So need to use webview 3+ without Ionic native 5+ wrapper like so: https://stackoverflow.com/a/54269144/1077309 |
fixed wkwebview bug #183 for iOS and removed deprecated method normalizeURL
After hours of trying a million suggestions, this is what worked. |
doing this broken all the image of the project. |
What worked for me is simply going to the package.json file of my project root, updating the "cordova-plugin-ionic-webview" entry like so: Then run the 2 commands:
|
the best solution to this problem is to start using Visual Studio and then install a Live Server Extention then go live command from the footer of the page. |
private win: any = window; let savePath = this.win.Ionic.WebView.convertFileSrc(path); |
Hi:
I using:
when i try to load an image, i get error:
"Not allowed to load local resource: file:///data/user/0/MI_APP_ID/cache/image-loader-cache/-919523643", source: http://localhost:8080/ (0)
any hint about this problem ?
thanks in advance.
The text was updated successfully, but these errors were encountered: