{"id":21173102,"url":"https://github.com/hughfenghen/opfs-tools","last_synced_at":"2025-05-15T18:03:14.912Z","repository":{"id":218210708,"uuid":"744307719","full_name":"hughfenghen/opfs-tools","owner":"hughfenghen","description":" A simple, high-performance, and comprehensive file system API running in the browser, built on OPFS.  在浏览器中运行的简单、高性能、完备的文件系统 API，基于 OPFS 构建。","archived":false,"fork":false,"pushed_at":"2025-03-23T10:03:37.000Z","size":570,"stargazers_count":250,"open_issues_count":1,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-01T01:36:30.855Z","etag":null,"topics":["browser","filesystem","fs","opfs","opfs-tools","tools","web"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hughfenghen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-17T02:57:11.000Z","updated_at":"2025-03-31T08:33:08.000Z","dependencies_parsed_at":"2024-05-19T13:49:44.686Z","dependency_job_id":"e4924b4e-14db-47f3-924a-2d3f34bd8612","html_url":"https://github.com/hughfenghen/opfs-tools","commit_stats":null,"previous_names":["hughfenghen/opfs-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hughfenghen%2Fopfs-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hughfenghen%2Fopfs-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hughfenghen%2Fopfs-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hughfenghen%2Fopfs-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hughfenghen","download_url":"https://codeload.github.com/hughfenghen/opfs-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247765458,"owners_count":20992314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","filesystem","fs","opfs","opfs-tools","tools","web"],"created_at":"2024-11-20T16:33:39.333Z","updated_at":"2025-04-08T02:35:43.726Z","avatar_url":"https://github.com/hughfenghen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"EN: A simple, high-performance, and comprehensive file system API running in the browser, built on [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system).\n\nCN: 在浏览器中运行的简单、高性能、完备的文件系统 API，基于 [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) 构建。\n\n[**API Documentation**](./docs/api.md) | [Tips](https://github.com/hughfenghen/opfs-tools/issues/18)\n\n[Benchmark](https://hughfenghen.github.io/opfs-tools/demo/benchmark.html)\n\n## Usage\n\n```js\nimport { file, dir, write } from 'opfs-tools';\n\n// --------- Create / Write ---------\nawait dir('/test-dir').create(); // create a directory\n\nawait write('/dir/file.txt', ''); // empty file\nawait write('/dir/fetch-file', (await fetch('//example.com')).body);\n// inputFile from the input element picked by the user\nawait write('/dir/input-file', inputFile.stream());\n\n// For incremental file writes, please refer to the API documentation.\nconst writer = await file('/dir/file').createWriter();\n\n// --------- Read ---------\nawait file('/dir/file.txt').text();\nawait file('/dir/input-file').arrayBuffer();\nawait file('/dir/input-file').stream();\n\n// If you want to read file fragments, please refer to the API documentation.\nconst reader = await file('/dir/input-file').createReader();\n\nawait dir('/test-dir').children();\n\n// --------- Remove ---------\nawait dir('/test-dir').remove();\n\nawait file('/dir/file.txt').remove();\n\n// --------- copyTo / moveTo ---------\nawait file('/dir/file').copyTo(file('/dir/file copy1'));\nawait dir('/dir').moveTo(dir('/.Trash'));\n\n// --------- import/export file  -----------\nconst [impHandle] = await window.showOpenFilePicker();\nwrite('/import-file', (await impHandle.getFile()).stream());\n\nconst expHandle = await window.showSaveFilePicker({\n  suggestedName: `opfs-export-file`,\n});\n(await file('/export-file').stream()).pipeTo(await expHandle.createWritable());\n\n// --------- upload -------------\nconst formData = new FormData();\nformData.append('file', await file('/upload-file').getOriginFile());\nawait fetch('/upload', {\n  method: 'post',\n  headers: { 'Content-Type': 'multipart/form-data' },\n  body: formData,\n});\n```\n\n[作者的 OPFS 相关文章](https://hughfenghen.github.io/tag/OPFS/)\n\n## DEMOS\n\n- [**opfs-finder**](https://github.com/hughfenghen/opfs-finder)  \n  使用 AI + OPFS 在浏览器中实现 MacOS Finder。Implement MacOS Finder in the browser using AI + OPFS.\n  \u003cimage src=\"https://github.com/user-attachments/assets/9daa5739-7561-425f-abb2-dcd5a5af519a\" width=\"700\"\u003e\n\n- [**opfs-tools-explorer**](https://github.com/hughfenghen/opfs-tools-explorer)  \n  Manage OPFS assets in your web site, supporting file creation, copying, and moving features, providing a user-friendly interactive experience.  \n  ![image](https://github.com/hughfenghen/opfs-tools/assets/3307051/1cf11bc7-92fb-4fde-9a18-5c7e81419e77)\n\n## Features\n\n- Basic operations\n  - [x] file\n    - [x] remove\n    - [x] exists\n  - [x] dir\n    - [x] create\n    - [x] remove\n    - [x] exists\n    - [x] children\n- [x] Reading files\n  - [x] getSize\n  - [x] text\n  - [x] stream\n  - [x] arrayBuffer\n- [x] Random reading\n  - [x] reader = file.createReader\n  - [x] reader.read(bufLen, { at }\n  - [x] reader.close\n- Writing files\n  - [x] write(dest: string, input: string)\n  - [x] write(dest: string, input: ArrayBuffer | ArrayBufferView)\n  - [x] write(dest: string, input: ReadableStream)\n- Random writing\n  - [x] writer = file.createWriter\n  - [x] writer.write\n  - [x] writer.flush\n  - [x] writer.truncate\n  - [x] writer.close\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhughfenghen%2Fopfs-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhughfenghen%2Fopfs-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhughfenghen%2Fopfs-tools/lists"}