Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created July 6, 2015 15:00
Show Gist options
  • Save joffilyfe/3f96a7ada2c6fc9f26a5 to your computer and use it in GitHub Desktop.
Save joffilyfe/3f96a7ada2c6fc9f26a5 to your computer and use it in GitHub Desktop.
Adicionando um arquivo utilizando a webapi do firefox OS
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