I'm implementing copy-paste functionality into a browser application using the ClipboardData API, as explained in this answer.
The FileReader::readAsDataURL(blob)
provides asynchronous reading of the file data, which is great.
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 DataTransferItem::getAsFile()
method asynchronous?
2) Is there a way to get FileReader
to take a DataTransferItem
as an argument so it can do the async
itself like it does already with blobs?
3) Am I out of luck?