FileReaderSync

由於本文件沒有此語言的翻譯版本,您閱讀的是英文版的內容。 幫助我們翻譯這篇文章!

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 Blob or a File into an ArrayBuffer representing the input data as a binary string.
FileReaderSync.readAsBinaryString()
This method converts a specified Blob or a File into a DOMString representing the input data as a binary string. This method is deprecated, consider using readAsArrayBuffer() instead.
FileReaderSync.readAsText()
This method converts a specified Blob or a File into a DOMString representing the input data as a text string. The optional encoding parameter 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 Blob or a File into a DOMString representing 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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
FileReaderSyncChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
readAsArrayBufferChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
readAsBinaryStringChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
readAsDataURLChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
readAsTextChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
Service workers support
DeprecatedNon-standard
Chrome No support ? — 59Edge ? Firefox No support ? — 61IE No support NoOpera No support ? — 46Safari No support NoWebView Android No support ? — 59Chrome Android No support ? — 59Firefox Android No support ? — 61Opera Android No support ? — 43Safari iOS No support NoSamsung Internet Android ?
Available in workersChrome Full support YesEdge Full support YesFirefox Full support 8IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 8Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

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.

See also