Your Search Results


    This article is in need of a technical review.

    This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

    This API is available on Firefox OS for privileged or certified applications only.


    The add method is used to add a file inside a given storage area.

    When a file is added with this method, its name is generated automatically and is available within the request's result which is a File object.


    var instanceOfDOMRequest = instanceOfDeviceStorage.add(file);


    A Blob object representing the file to add (note that a File object is also a Blob object).


    It returns a DOMRequest object to handle the success or error of the operation.


    var sdcard = navigator.getDeviceStorage("sdcard");
    var file   = new Blob(["This is a text file."], {type: "text/plain"});
    var request = sdcard.add(file);
    request.onsuccess = function () {
      var name =;
      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);


    Not part of any specification.

    See also

    Document Tags and Contributors

    Contributors to this page: kscarfone, fscholz, Jeremie
    Last updated by: fscholz,