--- title: FileReader.readAsBinaryString() slug: Web/API/FileReader/readAsBinaryString translation_of: Web/API/FileReader/readAsBinaryString ---
Метод readAsBinaryString используется для начала считывания содержимого определенного как {{domxref("Blob")}} или {{domxref("File")}}. Когда операция чтения завершится {{domxref("FileReader.readyState","readyState")}} становится DONE, и срабатывает {{event("loadend")}} . В это время атрибут {{domxref("FileReader.result","result")}} содержит сырые бинарные данные из файла.
Заметьте, что этот метод устарел (12 July 2012 Working Draft from the W3C.)
instanceOfFileReader.readAsBinaryString(blob);
blobvar canvas = document.createElement('canvas');
var height = 200;
var width = 200;
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
ctx.strokeStyle = '#090';
ctx.beginPath();
ctx.arc(width/2, height/2, width/2 - width/10, 0, Math.PI*2);
ctx.stroke();
canvas.toBlob(function (blob) {
var reader = new FileReader();
reader.onloadend = function () {
console.log(reader.result);
}
reader.readAsBinaryString(blob);
});
Этот метод был удален из стандарта FileAPI. Вместо него следует использовать {{domxref("FileReader.readAsArrayBuffer()")}}.
{{CompatibilityTable}}
| Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | {{CompatGeckoDesktop("1.9.2")}}[1] | 7 | {{CompatNo}} | 12.02[3] | 6.0 |
| Feature | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | 32 | 3 | 10 | 11.5 | 6.0 |
[1] Prior to Gecko 2.0 beta 7 (Firefox 4.0 beta 7), all {{domxref("Blob")}} parameters below were {{domxref("File")}} parameters; this has since been updated to match the specification correctly. Prior to Gecko 13.0 {{geckoRelease("13.0")}} the FileReader.error property returned a {{domxref("FileError")}} object. This interface has been removed and FileReader.error is now returning the {{domxref("DOMError")}} object as defined in the latest FileAPI draft.
[2] IE9 has a File API Lab.
[3] Opera has partial support in 11.1.