我正在使用xmlhttprequest下载文件(二进制数据,例如PDF)并保存到blob(在内存而不是磁盘中)。下载的字节数不正确。你能给我一些建议吗?
var url = ... // target file's url
var file_content = null;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET",url,false);
xmlhttp.send();
if(xmlhttp.status == 200){
file_content =xmlhttp.response; // file_content's length is not correct.
}
var blob = new Blob([file_content],{type: 'text/plain'} );