Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. FileReader
  4. readAsBinaryString()

FileReader: readAsBinaryString() method

Note: This feature is available inWeb Workers.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Note:This method is deprecated in favor ofreadAsArrayBuffer().

ThereadAsBinaryString() method of theFileReader interface is used to start reading the contents of thespecifiedBlob orFile. When the read operation isfinished, thereadyState property becomesDONE, and theloadend event is triggered. At that time, theresult property contains the raw binary data fromthe file.

Note that this method was once removed from the File API specification, butre-introduced for backward compatibility.UsingFileReader.readAsArrayBuffer() is recommended.

Syntax

js
readAsBinaryString(blob)

Parameters

blob

TheBlob orFile from which to read.

Return value

None (undefined).

Examples

js
const canvas = document.createElement("canvas");const height = 200;const width = 200;canvas.width = width;canvas.height = height;const ctx = canvas.getContext("2d");ctx.strokeStyle = "#009900";ctx.beginPath();ctx.arc(width / 2, height / 2, width / 2 - width / 10, 0, Math.PI * 2);ctx.stroke();canvas.toBlob((blob) => {  const reader = new FileReader();  reader.onload = () => {    console.log(reader.result);  };  reader.readAsBinaryString(blob);});

Specifications

Specification
File API
# readAsBinaryString

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp