Giter Club home page Giter Club logo

file-folder-picker-web-activity's Introduction

File and Folder Picker Web Activity

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.

Features

  • Pick a file (sends back file infos)
  • Pick a folder (sends back the path)

Requirements

Your app will need the permissions to access to SD card.

Why use it

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)

How to use it

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"
}

Misc

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.

Resources

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.