HTML5 and JavaScript: How to make paste processing completely / more asynchronous?

I implement copy-paste functions in a browser application using the ClipboardData API, as explained in this answer.

FileReader::readAsDataURL(blob) provides asynchronous reading of file data, which is excellent.

var items = (event.clipboardData || event.originalEvent.clipboardData).items;
var reader = new FileReader();
reader.onload = function(event){
   /*add item (i.e. image) to page*/}; //callback

var blob = items[0].getAsFile(); //not async
reader.readAsDataURL(blob); //async

Questions:
1) Is there a way to make the method DataTransferItem::getAsFile()asynchronous?
2) Is there a way to get FileReaderto take DataTransferItemas an argument so that it can do it itself asyncjust like using blobs?
3) Am I lucky?

+4
source share
1 answer

DataTransferItem:: getAsFile() ?

. . - - . , input.files , .

FileReader, DataTransferItem , async, blobs?

. item.getAsFile() blob .

0

Source: https://habr.com/ru/post/1526095/


All Articles