Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Input "type=file" doesn't work on Android #90

Open
atlowell-smpl opened this issue Jul 18, 2020 · 3 comments
Open

Input "type=file" doesn't work on Android #90

atlowell-smpl opened this issue Jul 18, 2020 · 3 comments

Comments

@atlowell-smpl
Copy link

Describe the bug
So it appears from my searches online that this bug is not unique to this project. It's existed for at least 9 years in various forms. Basically, any tags with type="file" set do nothing when pressed in android in a webview. Since Jasonette uses a webview, it would probably make sense to see if it could be addressed in our project. I've found this stackoverflow link (https://stackoverflow.com/questions/5907369/file-upload-in-webview) with a various number of answers. It seems like there's not one simple answer that works for all android versions.

Example Jasonette Document URL
Any url will show this, as long as it shows a page that has an in it.

Additional context>
You can use the $media.camera action instead of , but seeing as there seem to be several other issues with that functionality, it might be nice to fix this as a fallback,

@clsource
Copy link
Contributor

Hello, @atlowell-smpl yes it seems some web components need special considerations.
Thankfully Jasonelle can manage with a little help of agents. http://jasonelle.com/docs/legacy/agents/

and the http://jasonelle.com/docs/legacy/actions/#mediapicker native action.

Combining those two you can have the native media picker instead of the web view alternative, solving the issue :)

If you would like some examples you could look at the following example

https://github.com/jasonelle/beerjs

that helps demostrating using agents inside a webcontainer 👍

@atlowell-smpl
Copy link
Author

I actually made an attempt to do this in my app (with camera instead of mediapicker, but same principle), and I got almost there. Then I realized that the service I was using (bubble.io) required authentication headers to be specified for custom API requests, while clicking the input was handled by them automatically.

So I looked around more. I managed to get inputs working for API 21+ taking inspiration from the following repository:

https://github.com/mgks/Os-FileUp

It should be noted that I had to spread the code out between JasonViewActivity and JasonAgentService. I also had to change some of the code to use FileProvider to get it working on certain devices.

@clsource
Copy link
Contributor

Hello now Webview in Android works with file upload

https://github.com/jasonelle/jasonelle/issues/100

Please check it out 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants