firefox os - How to create directory on FirefoxOS apps in FirefoxOS device? -


i application create directory on firefoxos device.

anyone knows how that?

[addition] how create file

  1. [sdcard] = navigator.getdevicestorage( 'sdcard' )
  2. [blob object] = new blob()
  3. [sdcard].addnamed( [blob object], filename )

you have use full path relative device storage. directories automatically created when save file addnamed. let want save file named test.txt in folder examples of sdcard.

then you'll have save blob name examples/test.txt.

var sdcard = navigator.getdevicestorage("sdcard"); var file   = new blob(["this text file."], {type: "text/plain"}); var request = sdcard.addnamed(file, "examples/test.txt");  request.onsuccess = function () {   var name = this.result.name;   console.log('file "' + name + '" wrote on sdcard storage area'); }  request.onerror = function () {   console.warn('unable write file: ' + this.error); } 

here read mdn documentation:

note: repository in storage area implicit; it's not possible explicitly create empty repository. if want use repository structure have make part of name of file store. if want store file bar inside foo repository, have provide complete path name of file: addnamed(blob, "foo/bar").

as files added in given restricted storage area, security reasons, file path name cannot start "/" nor "../" (and "./" pointless).


Comments