-
Notifications
You must be signed in to change notification settings - Fork 760
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: - cordova.file.dataDirectory #509
Comments
Please have a look at this example app which shows how to download and display an image on Android 11 Cordova. |
@clarklight Did you find a solution for this using dataDirectory? We switched to use dataDirectory also (since that was supposed to be the safer option) and now we can't resolve the URLs for WebView, which obviously breaks our photo display. |
Nope, in the end i parsed the image into a base64 and stick the base64 into the src for displaying...for the time being, it isnt a great solution, as i believe it takes more memories? Not 100% sure. But atleast it displays the image....for now for my use case.... |
I was able to use This returns a ERR_ACCESS_DENIED message. If I get it as a cdvfile using toInternalURL ( I think this is a bug, as toURL should return a valid URL. This is only a problem when targeting API level 30. |
@grassick Can you try to communicate this to @alex-steinberg to verify this? Because i have not tried the toInternalURL method. Was your error the same as mine "Not allowed to load local resource:" ? |
@clarklight @alex-steinberg I found a solution! Upgrade to Cordova 11 with latest cordova-android. Use Then just use toURL, not toInternalURL. Voila! |
@grassick Did you simply add in the file transfer plugin and it worked? If so it could be a permission thing that was not set? |
The key difference, I think, was upgrading to the latest cordova-android (via Cordova 11) and then adding the AndroidInsecureFileModeEnabled. This isn't the soon-to-be-deprecated external storage, but rather a flag to run the app from |
The situation
I had been browsing through many other threads like this one #426 that talked about it would only affect cordova.file.external*
But every single one of the folder or directory, i can't read from, Nor can i write to any other folder, i can only write to the InternalStorage/Download folder.
When i add the photo file:///storage/emulated/0/Download/photoimg_id=1624.png to src tag, it will call the Not allowed to load local resource: error.
I calls the same error even i am using cordova.file.dataDirectory or any other folder.
I also tried to just use the example in the ReadMe.
And saved that image, and tried to append the SRC from FileEntry.nativeURL, it calls the Not allowed to load local resource: error again.
Currently i simply have no way to display an image from images stored inside the device.
Platform
Android 11
Cordova 10.0.0
Cordova-plugin-file 6.0.2
The text was updated successfully, but these errors were encountered: