FileReader extension type
The FileReader
object 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-domain.
- on
- Implemented types
- Available extensions
Constructors
- FileReader()
-
factory
Properties
- error → DOMException?
-
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
-
no setter
- result → JSAny?
-
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 beDONE
. -
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 withdispatchEvent()
.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 becomesDONE
, and theFileReader/loadend_event
is triggered. At that time, the FileReader.result attribute contains anArrayBuffer
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 becomesDONE
, and theFileReader/loadend_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 is changed toDONE
, theFileReader/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