How to go from Blob to ArrayBuffer

前端 未结 6 1035
旧时难觅i
旧时难觅i 2020-11-27 10:20

I was studying Blobs, and I noticed that when you have an ArrayBuffer, you can easily convert this to a Blob as follows:

var dataView = new DataView(arrayBuf         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 11:03

    await blob.arrayBuffer() is good.

    The problem is when iOS / Safari support is needed.. for that  one would need this:

    Blob.prototype.arrayBuffer ??=function(){ return new Response(this).arrayBuffer() }
    

提交回复
热议问题