movii
6/27/2017 - 3:52 PM

笔记:使用 JavaScript 识别文件 MIME TYPE 类型:5. 字节对其的例子

笔记:使用 JavaScript 识别文件 MIME TYPE 类型:5. 字节对其的例子

let str = 'abcde' 
  , strBlob = new Blob([str], {type: 'text/plain'})
  , FR = new FileReader();

FR.onloadend = (e) => {
  let af = e.target.result
    , uint8 = new Uint8Array(af);
  
  console.log('Uint8Array: ' + uint8);
}

FR.readAsArrayBuffer(strBlob)

// console 中得到的结果:
// Uint8Array: 97,98,99,100,101