{"id":15492469,"url":"https://github.com/juancastillo0/file_system_access_web","last_synced_at":"2025-04-10T19:11:42.746Z","repository":{"id":44410382,"uuid":"358982710","full_name":"juancastillo0/file_system_access_web","owner":"juancastillo0","description":"File System Access web API bindings for Dart and Flutter. https://developer.mozilla.org/Web/API/File_System_Access_API","archived":false,"fork":false,"pushed_at":"2025-03-16T23:40:22.000Z","size":11741,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T16:52:54.199Z","etag":null,"topics":["dart","filesystem","flutter","javascript","js","web"],"latest_commit_sha":null,"homepage":"https://juancastillo0.github.io/file_system_access_web/","language":"Dart","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/juancastillo0.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}},"created_at":"2021-04-17T21:08:46.000Z","updated_at":"2025-03-16T23:40:26.000Z","dependencies_parsed_at":"2023-01-29T19:30:31.250Z","dependency_job_id":null,"html_url":"https://github.com/juancastillo0/file_system_access_web","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancastillo0%2Ffile_system_access_web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancastillo0%2Ffile_system_access_web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancastillo0%2Ffile_system_access_web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juancastillo0%2Ffile_system_access_web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juancastillo0","download_url":"https://codeload.github.com/juancastillo0/file_system_access_web/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248279747,"owners_count":21077408,"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":["dart","filesystem","flutter","javascript","js","web"],"created_at":"2024-10-02T08:00:54.656Z","updated_at":"2025-04-10T19:11:42.741Z","avatar_url":"https://github.com/juancastillo0.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file_system_access\n\nThis package contains the bindings for the [File System Access web API](https://developer.mozilla.org/docs/Web/API/File_System_Access_API) implemented for some browsers.\n\n# Functionalities\n\nYou can view the [demo](https://juancastillo0.github.io/file_system_access_web/) for the main functionalities in this package. The main source code for the demo can be found in the [example/main.dart](https://github.com/juancastillo0/file_system_access_web/blob/main/example/lib/main.dart) file.\n\nYou can also view the main exposed API from this package in the [interface file](https://github.com/juancastillo0/file_system_access_web/blob/main/lib/src/file_system_access_interface.dart).\n\nMost APIs work for all platforms, desktop and mobile though `dart:io` and web with JavaScript bindings. One notable exception is `getPersistence` which is only implemented in web, since it would be easier to save the path of the file or directory along with any other data in native (non-web) platforms.\n\nThe `FileSystem.instance.isSupported` bool is true when the APIs implemented in this package are available in the user's device.\n\n## Files\n\nWith `showOpenFilePicker` you can ask the user to select files from the local file system. You can pass the extensions (.png, .pdf) that the files selected by the user should have. This will return the list of `FileSystemFileHandle`s to the user.\n\nThe `getFile` method in `FileSystemFileHandle` allows you to read the file contents and other information (last updated date, mime type, path on native platforms).\n\n### Permissions\n\nWith the `queryPermission` and `requestPermission` methods in a `FileSystemHandle` you can query and request \"read\" and \"readwrite\" permission to the user. This is available for directories and files.\n\nIn some browsers, the user may need to interact with the application first before you can request permissions. A \"Security Error\" will be thrown, the [demo](https://juancastillo0.github.io/file_system_access_web/) application shows it when you select something and refresh the page.\n\n### Write to files\n\nWith the `createWritable` method in a `FileSystemFileHandle` (that has \"readwrite\" permissions), you can edit the contents of the file.\n\n### `showSaveFilePicker`\n\nThis asks the user to select a file name and location for a new file which will have \"readwrite\" permissions. In this way, you can modify it and save it in the selected file system location.\n\n## Directories\n\nThe `showDirectoryPicker` function asks the user to select a directory. The selected directory will have \"read\" permissions.\n\nYou can use the `entries` method for retrieving all the items inside the directory or the `getFileHandle` and `getDirectoryHandle` using the name of each item.\n\nThe `resolve` method retuns a List of Strings with the path to the `FileSystemHandle` passed as argument or `null` if it is not a child of the directory.\n\n### Create and delete files\n\nWith a `FileSystemDirectoryHandle`, that has \"readwrite\" permissions, you can create files or directories using the `getFileHandle(create: true)` and `getDirectoryHandle(create: true)`. You can delete them with `removeEntry`.\n\n\n## Directory Synchronizer\n\nThe `DirectorySynchronizer` class allows you to sync an in-memory and editable directory abstraction with the persisted one in the user's machine.\n\n\n## Persistence with `getPersistence`\n\nThe `FileSystemPersistence` returned by `getPersistence` allows you to save a `FileSystemHandle` in the browser's IndexedDB. This is useful for maintaining the application state between sessions inside the browser.\n\nThis API is only available in web, you could save the path String in native platforms.\n\n### Usage\n\nFor Flutter, you will need to add the `assets/file_persistence.js` file to your assets in your `pubspec.yaml`:\n\n```yaml\n  assets:\n    - packages/file_system_access/assets/file_persistence.js\n```\n\nAnd then import it in you HTML:\n\n```html\n\u003cscript src=\"./assets/packages/file_system_access/assets/file_persistence.js\"\u003e\u003c/script\u003e\n```\n\nFor Dart web projects, you will need to import \"./packages/file_system_access/assets/file_persistence.js\" instead (without the first \"assets\" path).\n\nThe [demo](https://juancastillo0.github.io/file_system_access_web/) shows an example usage.\n\n# File System Access API documentation\n\nIn the following links you can find more about the API spec and documentation\n\nMDN:\nhttps://developer.mozilla.org/docs/Web/API/File_System_Access_API\n\nGitHub:\nhttps://github.com/WICG/file-system-access\n\nArticle:\nhttps://web.dev/file-system-access/\n\nWeb Platform Incubator Community Group - W3C:\nhttps://wicg.github.io/file-system-access/\n\nTypeScript definitions:\nhttps://www.npmjs.com/package/@types/wicg-file-system-access\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancastillo0%2Ffile_system_access_web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuancastillo0%2Ffile_system_access_web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuancastillo0%2Ffile_system_access_web/lists"}