Coder Social home page Coder Social logo

filesystemjs's Introduction

FileSystem JS

This is a JavaScript wrapper that provides a promise interface for working with the Chrome Browser FileSystem API. It is built with the aim of making it very easy to use. Hence, promises, rather than the default callbacks that the Native Implementations use.

Available Methods

  • Request Permission

    You can request permission to use the File System on your Web Application with

FileSystem.request()
            .then(function (fs) {
                console.log(fs) //[fs] is a FileSystem object
            })
            .catch(function (err) { 
                console.error(err)
            })
  • Create New File

    You can create a new file in the file system allocated to your application

FileSystem.createFile("log.txt")
            .then(function (fileEntry) { 
                console.log(fileEntry) //manipulate the new file
            })
            .catch(function (err) { 
                console.error(err) 
            })
  • Read File

    You can read a file already existing in the file system allocated to your application

FileSystem.readFile("log.txt")
            .then(function (fileEntry) { 
                console.log(fileEntry) //do stuff with the fileEntry
            })
            .catch(function (err) { 
                console.error(err) 
            })
  • Read File as Text

    You can read text from a file already existing in the file system allocated to your application

FileSystem.readFileText("log.txt")
            .then(function (textContent) { 
                console.log(textContent) //do stuff with the textContent
            })
            .catch(function (err) { 
                console.error(err) 
            })
  • Write Stuff to a File

    You can read text from a file already existing in the file system allocated to your application

FileSystem.writeFile("log.txt", new Blob(["Hello World"], { type: "text/plain" }))
            .then(function (fileEntry) { 
                console.log(fileEntry) //do stuff with the fileEntry
            })
            .catch(function (err) { 
                console.error(err) 
            })

Contributions

This was built to aid in a quick pet project, so there are a lot more methods people might need that are not available. Quick examples from the top of my head are:

  • Rename File
  • Delete File
  • Move File
  • Copy and Paste File
  • All other stuff with Directories

Make a pull request if you can, request for enhancements and raise issues here.

License

This project is licensed under the MIT License.

filesystemjs's People

Contributors

mykeels avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lillies77

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.