寻求基于FileSystem API的多文件批量下载JS库(适配Chromium)
多文件批量下载功能需求与疑问
我正在开发一个浏览器端纯HTML+JS画廊,需要实现无需客户端/服务端压缩的多文件批量下载功能。经调研,搭配FileSystemDirectoryHandle与window.showDirectoryPicker的FileSystem API可以满足需求——它允许用户选择目录并直接在其中创建文件,示例代码如下:
async function storeFileInDirectory() { const dirHandle = await window.showDirectoryPicker(dirPickOpts); const testFile = await dirHandle.getFileHandle("test.txt", {create: true}); const writable = await testFile.createWritable(); // Write the contents of the file to the stream. await writable.write("Test content."); // Close the file and write the contents to disk. await writable.close(); }
但我没找到实现该功能的现成库,想请教:是否存在可注册Worker、在后台下载文件列表并保存至磁盘(最好支持断点续传)的此类库?目前我找到的最优实现是Stack Overflow上的一份原型代码。
备注:我知晓window.showDirectoryPicker在Firefox 120中无法使用,本功能仅需支持Chromium浏览器即可。
内容的提问来源于stack exchange,提问作者arch
相关产品推荐
相关产品推荐

