jasonelle-v2 icon indicating copy to clipboard operation
jasonelle-v2 copied to clipboard

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

Open atlowell-smpl opened this issue 3 years ago • 3 comments

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,

atlowell-smpl avatar Jul 18 '20 01:07 atlowell-smpl

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 👍

clsource avatar Jul 18 '20 02:07 clsource

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.

atlowell-smpl avatar Jul 18 '20 23:07 atlowell-smpl

Hello now Webview in Android works with file upload

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

Please check it out 👍

clsource avatar Feb 10 '21 03:02 clsource