Giter Site home page Giter Site logo

file-system's Introduction

file-system

A slim wrapper around the Chrome filesystem API.

Install

npm install https://github.com/peermusic/file-system
var fs = require('file-system')(size, types)

For reference see the Browserify Handbook.

Demo

npm install -g wzrd
cd example
wzrd index.js:bundle.js

Note: If no local webserver (eg. wzrd) is used Chrome has to be started with the --allow-file-access-from-files flag.

Usage

// Require the module with the (optional) allowed file types
var types = ['audio/mp3', 'audio/wav', 'audio/ogg']
var fs = require('file-system')(types)

// Callback is a Node.js-typical callback that takes an error as the first
// parameter and a possible result as the second
var callback = function (err, result) {
  if (err) throw err
  console.log(result)
}

// Add a single file to the filesystem
// If filename is not set, file.name will be used
fs.add({filename: '...', file: File}, callback)

// Add a single file to the filesystem using a array buffer
fs.addArrayBuffer({filename: '...', arrayBuffer: ArrayBuffer)

// Add multiple files to the filesystem
fs.addMultiple([{filename: '...', file: File}, /* ... */], callback)

// Get the url to a file from the filesystem based on name
fs.get(filename, callback)

// Get a file as a data url from the filesystem based on name
fs.getDataUrl(filename, callback)

// Get a file as a array buffer from the filesystem based on name
fs.getArrayBuffer(filename, callback)

// Get all files in the filesystem
fs.list(callback)

// Delete a single file from the filesystem based on filename
fs.delete(filename, callback)

// Delete all files from the filesystem
fs.clear(callback)

file-system's People

Contributors

perguth avatar queicherius avatar ryomiyaichi avatar

Watchers

 avatar

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.