Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple, high-performance, and comprehensive file system API running in the browser, built on OPFS. 在浏览器中运行的简单、高性能、完备的文件系统 API,基于 OPFS 构建。

License

NotificationsYou must be signed in to change notification settings

hughfenghen/opfs-tools

Repository files navigation

EN: A simple, high-performance, and comprehensive file system API running in the browser, built onOPFS.

CN: 在浏览器中运行的简单、高性能、完备的文件系统 API,基于OPFS 构建。

API Documentation |Tips

Benchmark

Usage

import{file,dir,write}from'opfs-tools';// --------- Create / Write ---------awaitdir('/test-dir').create();// create a directoryawaitwrite('/dir/file.txt','');// empty fileawaitwrite('/dir/fetch-file',(awaitfetch('//example.com')).body);// inputFile from the input element picked by the userawaitwrite('/dir/input-file',inputFile.stream());// For incremental file writes, please refer to the API documentation.constwriter=awaitfile('/dir/file').createWriter();// --------- Read ---------awaitfile('/dir/file.txt').text();awaitfile('/dir/input-file').arrayBuffer();awaitfile('/dir/input-file').stream();// If you want to read file fragments, please refer to the API documentation.constreader=awaitfile('/dir/input-file').createReader();awaitdir('/test-dir').children();// --------- Remove ---------awaitdir('/test-dir').remove();awaitfile('/dir/file.txt').remove();// --------- copyTo / moveTo ---------awaitfile('/dir/file').copyTo(file('/dir/file copy1'));awaitdir('/dir').moveTo(dir('/.Trash'));// --------- import/export file  -----------const[impHandle]=awaitwindow.showOpenFilePicker();write('/import-file',(awaitimpHandle.getFile()).stream());constexpHandle=awaitwindow.showSaveFilePicker({suggestedName:`opfs-export-file`,});(awaitfile('/export-file').stream()).pipeTo(awaitexpHandle.createWritable());// --------- upload -------------constformData=newFormData();formData.append('file',awaitfile('/upload-file').getOriginFile());awaitfetch('/upload',{method:'post',headers:{'Content-Type':'multipart/form-data'},body:formData,});

作者的 OPFS 相关文章

DEMOS

  • opfs-finder
    使用 AI + OPFS 在浏览器中实现 MacOS Finder。Implement MacOS Finder in the browser using AI + OPFS.

  • opfs-tools-explorer
    Manage OPFS assets in your web site, supporting file creation, copying, and moving features, providing a user-friendly interactive experience.
    image

Features

  • Basic operations
    • file
      • remove
      • exists
    • dir
      • create
      • remove
      • exists
      • children
  • Reading files
    • getSize
    • text
    • stream
    • arrayBuffer
  • Random reading
    • reader = file.createReader
    • reader.read(bufLen, { at }
    • reader.close
  • Writing files
    • write(dest: string, input: string)
    • write(dest: string, input: ArrayBuffer | ArrayBufferView)
    • write(dest: string, input: ReadableStream)
  • Random writing
    • writer = file.createWriter
    • writer.write
    • writer.flush
    • writer.truncate
    • writer.close

About

A simple, high-performance, and comprehensive file system API running in the browser, built on OPFS. 在浏览器中运行的简单、高性能、完备的文件系统 API,基于 OPFS 构建。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp