HTML5 FileReader

Object to allow reading of files


Learning Resources:

Sample - Using FileReader to upload a picture using the camera Sample that demonstrates how to use the HTML5 FileReader API [BlackBerry on GitHub].

Supported Platform(s)

- BlackBerry OS 5.0+
- BlackBerry PlayBook 1.0+
- BlackBerry 10
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
abort Y Y Y Y Y   
readAsDataURL Y Y Y Y Y   
readAsText       Y Y Y 
error       Y Y Y 
readyState       Y Y Y 
result       Y Y Y 
FileReader.onabort       Y Y Y 
FileReader.onerror       Y Y Y 
FileReader.onload       Y Y Y 
FileReader.onloadend       Y Y Y 
FileReader.onloadstart       Y Y Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

This API does not require a <feature> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Permission Elements (PlayBook and BlackBerry 10+)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Functions

void abort
void readAsDataURL
void readAsText


Properties

void error
String readyState
String result

Functions

void abort ()


function to abort the fileReading process


Supported Platforms
 - BlackBerry OS 5.0+
 - BlackBerry PlayBook 1.0+


Code Example:
function win(file) {
      var reader = new FileReader();
      reader.onloadend = function(evt) {
          console.log("read success");
          console.log(evt.target.result);
      };

     reader.readAsText(file);
     reader.abort();
};

function fail(error) {
     console.log(error.code);
}

entry.file(win, fail);

void readAsDataURL ()


function to read the file and return the data as a base64 encoded data url


Supported Platforms
 - BlackBerry OS 5.0+
 - BlackBerry PlayBook 1.0+

void readAsText ()


function to read the text file and returns the data as text


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

Events

static void FileReader.onabort ()


function that is called when the read has been aborted


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static void FileReader.onerror ()


assigned to the function that will be executed when there is an error


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static void FileReader.onload ()


assigned to the function that is called when the read starts


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static void FileReader.onloadend ()


function that is called when file reading has been completed


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static void FileReader.onloadstart ()


the function that is called when the read starts


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

Properties

static readonly void error


An object containing errors. (FileError)


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static readonly String readyState


Description of what state the reader can be. File Reader can be one of three states: EMPTY, LOADING or DONE


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

static readonly String result


The contents of the file that has been read.


Supported Platforms
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 11 2013 14:51:07 GMT-0500 (EST)