This is file & folder picker intended to be used as a web activity from a FirefoxOS app
It is a stripped down fork of File Manager, only keeping the ability to select files and folders.
- Pick a file (sends back file infos)
- Pick a folder (sends back the path)
Your app will need the permissions to access to SD card.
Use this if
- You need to pick an arbitrary file or folder on your FirefoxOS app
- The default apps aren't enough (eg. you do not want a picture/music/video)
- You don't want to rely on the presence of another app to do this (eg. File Manager)
Clone this repository into your app.
Add the following to your manifest.webapp
:
{
"activities": {
"pick-file": {
"disposition": "inline",
"returnValue": true,
"href": "/path/to/this/repo/index.html"
},
"pick-folder": {
"disposition": "inline",
"returnValue": true,
"href": "/path/to/this/repo/index.html"
},
}
}
Then in your app, call the activity like this:
var activity = new MozActivity({
name: "pick-file" // Or pick-folder
});
activity.onsuccess = function() {
console.log(this.result);
};
activity.onerror = function() {
console.log(this.error);
};
The Picker will send to your app the following data for a file:
{
"type": "image/svg+xml",
"filename": "/sdcard/image.svg",
"blob": [object Blob],
"allowSave": false
}
For a folder:
{
"path": "path/to/your/folder"
}
You should change the activities' names to specific to your app if you don't want other apps calling the activity (for example, "pick-file@hugo/conteur").
The names need to contain "file" or "folder" for the picker to know what to work with.
This project is open source under GPL license as is the original File Manager Uses a variant of Building Blocks library and icon theme from Numix Circle.