FileReader: readAsArrayBuffer() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("File API")}}{{AvailableInWorkers}}

The **readAsArrayBuffer()** method of the {{domxref("FileReader")}} interface is used to start reading the contents of a specified {{domxref("Blob")}} or {{domxref("File")}}. When the read operation is finished, the {{domxref("FileReader.readyState","readyState")}} property becomes DONE, and the {{domxref("FileReader/loadend_event", "loadend")}} event is triggered. At that time, the {{domxref("FileReader.result","result")}} property contains an {{jsxref("ArrayBuffer")}} representing the file's data.

توجه: The {{domxref("Blob.arrayBuffer()")}} method is a newer promise-based API to read a file as an array buffer.

Syntax

js-nolint
readAsArrayBuffer(blob)

Parameters

  • blob
  • : The {{domxref("Blob")}} or {{domxref("File")}} from which to read.

Return value

None ({{jsxref("undefined")}}).

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("FileReader")}}