-
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
feat(android): add WebViewAssetLoader proxy handler for cdvfile #513
feat(android): add WebViewAssetLoader proxy handler for cdvfile #513
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
helpful |
Sorry if this is the wrong place to ask, but as the current latest version is from 2019, once this gets merged how long is it likely to be for a new release to be available? Or will I need to build the plugin myself somehow rather than using cordova plugin add... ? |
@skmbr I can not give you an exact answer, but hoping to prepare a release shortly after. This PR fixes a lot of the issues but I am trying to investigate one alternative solution. (This explains why I have the PR in draft.) I am hoping with the alternative solution I will not need to introduce new front-end JS code (E.g. My vision of the alternative solution's use cases is:
Because As a side note, the alternative solution would still use all of the native changes I made in this PR. |
@erisu That's good to hear! Thank you! That alternative solution sounds great too.
One thing I will say is that toInternalURL was returning a cdvfile url for me after enabling AndroidInsecureFileModeEnabled so I had to switch to toURL to get a file:// url. Looking forward to this being solved so I can do a proper release of my app again. Luckily I have codepush so have still been able to get fixes and small updates out, but getting to the point where I need a full release targeting > SDK 30 to keep up with new features in the iOS version. Thanks again for all your work on this! |
Facing the same issue. Any updates about this PR ? |
Thanks for your work! I'm waiting for this to update my app! |
I updated the PR description to reflect the latest changes. Read the sections |
We could add the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested via using camera plugin to snap a picture and then passing the provided URL to the file plugin to resolve to a FileEntry, then use .toURL()
to display in the DOM.
…le (apache#513)" This reverts commit 3366ea6.
…le (apache#513)" This reverts commit 3366ea6.
@erisu Great that this is merged in now. Thanks for all your hard work! Any news on when there might be a release? Or is the only option to install it via the github url? |
@erisu Its working fine when i'm installing latest plugin for the the first time, when i uninstall and try to reinstall its throwing me error in 'cordova-plugin-advanced-http' code |
…he#513) * feat: add WebAssetLoader proxy handler for cdvfile * fix: update the fileTarget replace string * chore: make androidx.webkit:webkit configurable & default to 1.4.0 * feat: toURL to return file or custom scheme based on window location * chore: remove unused variable * chore: add other file systems to check * chore: remove comment * feat: bump cordova-android requirement to >=10.0.0 for AndroidX usage * doc: updated readme to include the Android changes
Hi there, this one is creating the URL that my Android app is not able to recognize. The URL constantly returns "not found" on the device, although it exists when I check file system. Can anyone help on this? |
So while this URL was resolved correctly with version 6.0.2
on 7.0.0 I get error 1 (not found) |
Motivation and Context
Fetching files from the
persistent
andtemporary
file systen while using custom scheme+hostname.Description
This PR adds a proxy handler for the WebViewAssetLoader.
Since
cdvfile://localhost
no longer works, this PR implements a new URL pattern that works with custom scheme+hostname. It will fetch and return a WebResponse of the file located in the native file system.E.g.:
Old cdvfile URL:
will become:
and continue to map to the native file:
If you configure the app to use
http
or with a differenthostname
, other thenlocalhost
, it will change as such.Resolves:
Need confirmation:
Depending on use case and app configuration, it appears that many the file url was being used when the app is served though the custom scheme+hostname setup. Only with
AndroidInsecureFileModeEnabled
will the file path work. This PR will introduce changes which will make it possible to load files with the custom scheme+hostname setup but with a different URL structure.Usage:
Use
toURL
, NOTtoInternalURL
.The
toURL
method will call thetoInternalURL
when necessary.IF
AndroidInsecureFileModeEnabled
is set tofalse
or not defined, thetoURL
method will call and return the results fromtoInternalURL
.Example result:
https://localhost/__cdvfile_persistent__/image.png
.The scheme and hostname may vary depending on its configurations.
IF
AndroidInsecureFileModeEnabled
is set totrue
, thetoURL
method will return the native URL.Example Result:
file:///data/user/0/<APP ID>/files/files/image.png
.What happens if
toInternalURL
is called directly?AndroidInsecureFileModeEnabled
is set tofalse
or not defined, calling thetoInternalURL
method will not have any negative effect. The correct URL pattern will be returned.AndroidInsecureFileModeEnabled
is set totrue
, calling thetoInternalURL
method will return a URL pattern that does not exist and is reachable. This will cause issues in fetching and loading of resources.Testing
npm t
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)