我正在玩FileSystem API.
我发现了很多例子,你生成一个下载链接让用户下载文件"浏览器方式".
我想知道两件事:
有没有办法将小提琴中的ajax结果直接写入磁盘(没有任何类型的提示).比如用户的桌面.
blob是最合适的格式吗?
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200){
console.log(this.response, typeof this.response);
var img = document.getElementById('img');
var url = window.URL = window.webkitURL;
img.src = url.createObjectURL(this.response);
}
}
xhr.open('GET', 'http://www.newyorker.com/online/blogs/photobooth
/NASAEarth-01.jpg');
xhr.responseType = 'blob';
xhr.send();
Run Code Online (Sandbox Code Playgroud) 有一个文件系统 API,但现在显示为已弃用: https:
//developer.mozilla.org/en-US/docs/Web/API/Window/requestFileSystem
现在还有另一个文件系统访问 API:
https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
旧 API 发生了什么情况以及为何停止使用?新的文件系统访问 API 在所有常见浏览器中是否应该稳定?