FileReader extension type

The FileReader interface lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read.

File objects may be obtained from a FileList object returned as a result of a user selecting files using the input element, or from a drag and drop operation's DataTransfer object.

FileReader can only access the contents of files that the user has explicitly selected, either using an HTML <input type="file"> element or by drag and drop. It cannot be used to read a file by pathname from the user's file system. To read files on the client's file system by pathname, use the File System Access API. To read server-side files, use fetch, with CORS permission if reading cross-origin.


API documentation sourced from MDN Web Docs.

on
Implemented types
Available extensions

Constructors

FileReader()
factory

Properties

error DOMException?
The error read-only property of the FileReader interface returns the error that occurred while reading the file.
no setter
hashCode int
The hash code for this object.
no setterinherited
onabort EventHandler?
getter/setter pair
onerror EventHandler?
getter/setter pair
onload EventHandler?
getter/setter pair
onloadend EventHandler?
getter/setter pair
onloadstart EventHandler?
getter/setter pair
onprogress EventHandler?
getter/setter pair
readyState int
The readyState read-only property of the FileReader interface provides the current state of the reading operation. This will be one of the states: EMPTY, LOADING, or DONE.
no setter
result JSAny?
The result read-only property of the FileReader interface returns the file's contents. This property is only valid after the read operation is complete, and the format of the data depends on which of the methods was used to initiate the read operation.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

abort() → void
The abort() method of the FileReader interface aborts the read operation. Upon return, the FileReader.readyState will be DONE.
addEventListener(String type, EventListener? callback, [JSAny options]) → void
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
inherited
dispatchEvent(Event event) bool
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAsArrayBuffer(Blob blob) → void
The readAsArrayBuffer() method of the FileReader interface is used to start reading the contents of a specified Blob or File. When the read operation is finished, the FileReader.readyState property becomes DONE, and the FileReader.loadend_event event is triggered. At that time, the FileReader.result property contains an ArrayBuffer representing the file's data.
readAsBinaryString(Blob blob) → void

Note: This method is deprecated in favor of FileReader.readAsArrayBuffer.

readAsDataURL(Blob blob) → void
The readAsDataURL() method of the FileReader interface is used to read the contents of the specified Blob or File. When the read operation is finished, the FileReader.readyState property becomes DONE, and the FileReader.loadend_event event is triggered. At that time, the FileReader.result attribute contains the data as a data: URL representing the file's data as a base64 encoded string.
readAsText(Blob blob, [String encoding]) → void
The readAsText() method of the FileReader interface is used to read the contents of the specified Blob or File. When the read operation is complete, the FileReader.readyState property is changed to DONE, the FileReader.loadend_event event is triggered, and the FileReader.result property contains the contents of the file as a text string.
removeEventListener(String type, EventListener? callback, [JSAny options]) → void
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

DONE → const int
EMPTY → const int
LOADING → const int