`title: OPFS 导出到用户目录:File System Access 目录桥接``categories: Web 开发/前端/数据管理``keywords: OPFS,File System Access,showDirectoryPicker,导出,备份``description: 使用 File System Access 的目录选择将 OPFS 文件导出到用户目录,实现备份与跨设备迁移的友好体验。`导出示例async function exportOPFS() { const root = await navigator.storage.getDirectory(); const dest = await window.showDirectoryPicker(); for await (const [name, handle] of root.entries()) { if (handle.kind === 'file') { const file = await handle.getFile(); const out = await dest.getFileHandle(name, { create: true }); const w = await out.createWritable(); await w.write(await file.arrayBuffer()); await w.close(); } } }

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
2.071505s