FileReader.readAsBinaryString()

Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

O método readAsBinaryString é usado para iniciar a leitura do conteúdo de um Blob especificado, ou File. Quando a operação de leitura é finalizada, o readyState se torna "DONE", e o evento loadend é acionado. Neste momento, o atributo result contém o dado binário bruto do arquivo.

Note que este método se tornou obsoleto desde 12 de Julho de 2012 Working Draft do W3C.

Sintaxe

instanciaDeFileReader.readAsBinaryString(blob);

Parametros

blob

O Blob ou File que deseja ler.

Exemplo

js
var 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);
});

Especificações

Specification
File API
# readAsBinaryString

Compatibilidade com navegadores

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
readAsBinaryString
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Deprecated. Not for use in new websites.

Veja Também