fileStorage

storage?

0?

0?

storage?,database?

...

initiate code Toggle

var file = fileStorage({
    Base: 'storage',
    RequestQuota: 1073741824,
    Permission: 1,
    objectStore:{
      name:'fileStorage',
      version:1,
      file:'file',
      other:{
       name:'otherName',option:{}
      }
    }
  },
  {
    done: function(status) {
      // NOTE: doneCallback!
      // REVIEW: executed either success or fail!
    },
    fail: function(status) {
      // NOTE: failCallback
      // REVIEW: executed to warn the Browser does not support 'requestFileSystem'!
    },
    success: function(fs) {
      // NOTE: successCallback
      // REVIEW: Browser supports 'requestFileSystem' or 'IndexedDB'!
    }
  }
);

url

requestMethod

requestCache

responseType

readAs

urlLocal

how download work!

file.download({
  url: 'http://www.example.com/file.xml',
  urlLocal: 'filename.xml',
  // urlLocal===true -> file.xml
  // readAs: 'createObjectURL',
  // [readAsText,readAsArrayBuffer,readAsDataURL,readAsBinaryString]
  // requestMethod: 'GET', [GET,POST]
  // requestCache:false, [true]
  before: function(xmlHttp){
  },
  progress: function(Percentage){
    console.log(Percentage);
  }
}).then(function(e){
  console.log('success');
},function(e){
  console.log('fail');
}).then(function(e){
  console.log('done');
});

fileContent

fileType

urlLocal

how save work!

file.save({
  urlLocal: 'directory/filename.txt',
  blob: new Blob(['this is plain text'], {type: 'text/plain; charset=utf-8'}),
  // data: 'this is plain text',
  // fileContent: 'this is plain text',
  fileType: 'text/plain'
}).then(function(e){
  console.log('success');
},function(e){
  console.log('fail');
}).then(function(e){
  console.log('done');
});

urlLocal

Update

readAs

how open work!

file.open({
  urlLocal: 'directory/filename.txt',
  readAs: 'createObjectURL'
}).then(function(e){
  console.log('success');
},function(e){
  console.log('fail');
}).then(function(e){
  console.log('done');
});

urlLocal

Update

how delete work!

file.delete({
  urlLocal: 'directory/filename.txt',
  fileNotFound: true // fileNotFound if true return successCallback, even the file is not found!
}).then(function(e){
  console.log('success');
},function(e){
  console.log('fail');
}).then(function(e){
  console.log('done');
});

url

requestMethod

requestCache

responseType

readAs

urlLocal

fileContent

defined by "readAs"

fileType

defined by "XMLHttpRequest"

how download then save work!

file.download({
  url: 'http://www.example.com/file.xml',
  urlLocal: true,
  readAs: 'createObjectURL'
  fileOption:{
    create:true
  },
  before: function(xmlHttp){
    xmlHttp.responseType='blob';
  },
  progress: function(Percentage){
    console.log(Percentage);
  }
}).then(function(e){
  console.log('success');
},function(e){
  console.log('fail');
}).then(function(e){
  console.log('done');
});