FileReader Object Error: FileReader Error: Object is already busy reading blob

    var blob = this .file.slice( this .readed, this .readed + this .step);
             this .reader.readAsArrayBuffer(blob);

 

Solution:

When the reader reads, first judge the readyState value, and then execute the reading if it is not loading.

    if  (this.reader.readyState == 1)
                 return ;
             var blob = this .file.slice( this .readed, this .readed + this .step);
             this .reader.readAsArrayBuffer(blob);

 

 

readyState FileReader

value condition describe
0 EMPTY Reader has been created. No read methods have been called yet.
1 LOADING The read method has been called.
2 DONE The operation is complete.
EMPTY
Created, but the readAs method has not yet been called .FileReader
LOADING
The readAs method is called. An or is being read , but an error has not yet occurred.FileBlob
DONE
The read operation is complete. This could mean: the whole or was read into memory, a file read error occurred, or the read was canceled when called.FileBlobabort()
var reader = new FileReader(); 
console.log( 'EMPTY', reader.readyState); // readyState will be 0 

reader.readAsText(blob); 
console.log( 'LOADING', reader.readyState); // readyState will be 1 

reader.onloadend = function () { 
  console.log( 'DONE', reader.readyState); // readyState will be 2 
};

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *