Created
July 6, 2015 15:00
-
-
Save joffilyfe/3f96a7ada2c6fc9f26a5 to your computer and use it in GitHub Desktop.
Adicionando um arquivo utilizando a webapi do firefox OS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sdcard = navigator.getDeviceStorage("sdcard"); | |
var file = new Blob(["This is a text file."], {type: "text/plain"}); | |
var request = sdcard.addNamed(file, "my-file.txt"); | |
request.onsuccess = function () { | |
var name = this.result; | |
console.log('File "' + name + '" successfully wrote on the sdcard storage area'); | |
} | |
// An error typically occur if a file with the same name already exist | |
request.onerror = function () { | |
console.warn('Unable to write the file: ' + this.error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment