Skip to content

FileQueue in JS - set, store, get, delete, clear Files in IndexedDB. To be used as a upload queue.

Notifications You must be signed in to change notification settings

piatkowski/filequeue.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FileQueue in JavaScript

Simple lib for storing file input in IndexedDB with Promises (async js)

Methods

FileQueue.add(key, file); // add file to the queue with "key: identifier
FileQueue.push(); // push files content to the IndexedDB
FileQueue.delete(key); // delete key from IndexedDB
FileQueue.clear(); // clear queue and data in IndexedDB
FileQueue.getInfo(key); // get item from queue

@todo:
FileQueue.get(key); //get file from IndexedDB

Usage

1 . create new FileQueue with parameters

let queue = new FileQueue({
    db: 'db_name',
    store: 'store_name'
});

2 . Get file from user input

let file = document.getElementById('input').files[0];

3 . Add file to the queue and push to IDB

queue.add('key', file); // can add many files
queue.push().then(() => {
    console.log("All files saved to IDB!"); //callback
});

4 . Clear queue and IDB

queue.clear().then(() => {
    console.log("Cleared!");
});

Todo

Read files from IDB and prepare for ajax upload.

About

FileQueue in JS - set, store, get, delete, clear Files in IndexedDB. To be used as a upload queue.

Resources

Stars

Watchers

Forks

Packages

No packages published