Search code examples
webapp2firefox-os

Firefox webapp file input


I'm developing a webapp for firefox aurora (android). And i have an file input. But when users click on the input they can't choose files from sdcard or filesystem only pictures, music or videos.

I search at MOZILLA DEVELOPER NETWORK, but couldn't find anything helpful.

In my manifest.webbapp i have device-storage permission:

"permissions": {
    "device-storage:sdcard":{ "access": "readonly" }
  },

enter image description here


Solution

  • I assume you are currently simply using the markup ?

    The device-storage:sdcard is for a very different set of use cases really. And we don't have that implemented on Firefox for Android yet.

    The list of applications being shown is just the set of applications that we're getting from the Android Intents system. I would imagine that if the user has some sort of filebrowser app installed it might respond to that intent and it'd pop up there.

    But of course that's not something you can rely on in your app.

    I'm honestly somewhat surprised that there's no default applications on android that provide that functionality, but I guess that's how it is. Or does someone know of a way to also get a filepicker intent that we can hook up to?

    Medium term you will be able to use the DeviceStorage API. This will give you direct JS access to the sdcard which will allow you to build your own UI for choosing a file from the SD card. But that extra power comes with quite a few downsides. It's a privileged API which means that you'll have to write the app as a packaged app and you have to use CSP. And you'll have to go through the Firefox marketplace review process (all privileged apps have to go through code review).

    So it's a pretty distant second choice.

    Other than that there aren't any solutions. The best would of course be if there was a way we could plopp up an Android file picker, but I'm not sure if that's doable. And it's definitely not implemented yet.