The FileReaderSync interface allows to read File or Blob objects synchronously.
This interface is only available in workers as it enables synchronous I/O that could potentially block.
Properties
This interface does not have any properties.
Methods
FileReaderSync.readAsArrayBuffer()- This method converts a specified
Blobor aFileinto anArrayBufferrepresenting the input data as a binary string. FileReaderSync.readAsBinaryString()- This method converts a specified
Blobor aFileinto aDOMStringrepresenting the input data as a binary string. This method is deprecated, consider usingreadAsArrayBuffer()instead. FileReaderSync.readAsText()- This method converts a specified
Blobor aFileinto aDOMStringrepresenting the input data as a text string. The optionalencodingparameter indicates the encoding to be used (e.g., iso-8859-1 or UTF-8). If not present, the method will apply a detection algorithm for it. FileReaderSync.readAsDataURL()- This method converts a specified
Blobor aFileinto aDOMStringrepresenting the input data as a data URL.
Specifications
| Specification | Status | Comment |
|---|---|---|
| File API The definition of 'FileReaderSync' in that specification. |
Working Draft | Initial definition. |
Browser Compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileReaderSync | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
readAsArrayBuffer | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
readAsBinaryString | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
readAsDataURL | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
readAsText | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
| Service workers support | Chrome No support ? — 59 | Edge ? | Firefox No support ? — 61 | IE No support No | Opera No support ? — 46 | Safari No support No | WebView Android No support ? — 59 | Chrome Android No support ? — 59 | Firefox Android No support ? — 61 | Opera Android No support ? — 43 | Safari iOS No support No | Samsung Internet Android No support ? — 7.0 |
| Available in workers | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 8 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 8 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
