mozilla
Your Search Results

    DeviceStorage.get()

    This article is in need of a technical review.

    Non-standard
    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.

    Summary

    The get method is used to retrieve a read-only file from a given storage area.

    If the request is successful, the request's result is a File object containing the data of the original file on the device.

    Syntax

    var instanceOfDOMRequest = instanceOfDeviceStorage.get(fileName);

    Parameters

    fileName
    A string representing the full name (path + file name) of the file to retrieve.

    Returns

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

    Example

    var sdcard = navigator.getDeviceStorage("sdcard");
    
    var request = sdcard.get("myFile.txt");
    
    request.onsuccess = function () {
      var name = this.result.name;
      console.log('File "' + name + '" successfully retrieved from the sdcard storage area');
    }
    
    request.onerror = function () {
      console.warn('Unable to get the file: ' + this.error);
    }
    

    Specification

    Not part of any specification.

    See also

    Document Tags and Contributors

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