{"id":15092992,"url":"https://github.com/kristofferstrube/blazor.filesystemaccess","last_synced_at":"2025-04-05T15:06:45.851Z","repository":{"id":38012989,"uuid":"462486581","full_name":"KristofferStrube/Blazor.FileSystemAccess","owner":"KristofferStrube","description":"A Blazor wrapper for the File System Access browser API.","archived":false,"fork":false,"pushed_at":"2024-08-04T10:04:27.000Z","size":13078,"stargazers_count":342,"open_issues_count":9,"forks_count":40,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-05T15:06:41.725Z","etag":null,"topics":["blazor","blazor-interop","blazor-webassembly","csharp","editor","filesystemaccess","filesystemaccessapi","github-actions","github-pages","jsinterop","wrapper"],"latest_commit_sha":null,"homepage":"https://kristofferstrube.github.io/Blazor.FileSystemAccess/","language":"C#","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/KristofferStrube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2022-02-22T21:51:00.000Z","updated_at":"2025-03-24T02:24:50.000Z","dependencies_parsed_at":"2024-04-10T02:56:07.709Z","dependency_job_id":"f60a98ce-65f3-4422-950b-f2ba32fed723","html_url":"https://github.com/KristofferStrube/Blazor.FileSystemAccess","commit_stats":{"total_commits":111,"total_committers":6,"mean_commits":18.5,"dds":"0.11711711711711714","last_synced_commit":"727c40232d69512bf4619c481aef67654e21f3c5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.FileSystemAccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.FileSystemAccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.FileSystemAccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.FileSystemAccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KristofferStrube","download_url":"https://codeload.github.com/KristofferStrube/Blazor.FileSystemAccess/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"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":["blazor","blazor-interop","blazor-webassembly","csharp","editor","filesystemaccess","filesystemaccessapi","github-actions","github-pages","jsinterop","wrapper"],"created_at":"2024-09-25T11:02:34.932Z","updated_at":"2025-04-05T15:06:45.832Z","avatar_url":"https://github.com/KristofferStrube.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](/LICENSE.md)\n[![GitHub issues](https://img.shields.io/github/issues/KristofferStrube/Blazor.FileSystemAccess)](https://github.com/KristofferStrube/Blazor.FileSystemAccess/issues)\n[![GitHub forks](https://img.shields.io/github/forks/KristofferStrube/Blazor.FileSystemAccess)](https://github.com/KristofferStrube/Blazor.FileSystemAccess/network/members)\n[![GitHub stars](https://img.shields.io/github/stars/KristofferStrube/Blazor.FileSystemAccess)](https://github.com/KristofferStrube/Blazor.FileSystemAccess/stargazers)\n[![NuGet Downloads (official NuGet)](https://img.shields.io/nuget/dt/KristofferStrube.Blazor.FileSystemAccess?label=NuGet%20Downloads)](https://www.nuget.org/packages/KristofferStrube.Blazor.FileSystemAccess/)  \n\n# Introduction\nA Blazor wrapper for the browser API [File System Access](https://wicg.github.io/file-system-access)\n\nThe API makes it possible to read and write to your local file system from the browser both files and directories.\n\n_Disclaimer: The API is supported on a limited set of browsers. Most noticeable not supported on Firefox, Chrome for Android, and iOS mobile browsers._\n\n## Demo\nThe sample project can be demoed at https://kristofferstrube.github.io/Blazor.FileSystemAccess/\n\nOn each page you can find the corresponding code for the example in the top right corner.\n\nOn the main page you can see if the API has at least minimal support in the used browser.\n\nOn the [Status page](https://kristofferstrube.github.io/Blazor.FileSystemAccess/Status) you can see how much of the WebIDL specs this wrapper has covered.\n\n# Getting Started\n## Prerequisites\nYou need to install .NET 7.0 or newer to use the library.\n\n[Download .NET 7](https://dotnet.microsoft.com/download/dotnet/7.0)\n\n## Installation\nYou can install the package via Nuget with the Package Manager in your IDE or alternatively using the command line:\n```bash\ndotnet add package KristofferStrube.Blazor.FileSystemAccess\n```\n\n# Usage\nThe package can be used in Blazor WebAssembly and Blazor Server projects. (Note that streaming of big files is not supported in Blazor Server due to bandwidth problems.)\n## Import\nYou also need to reference the package in order to use it in your pages. This can be done in `_Import.razor` by adding the following.\n```razor\n@using KristofferStrube.Blazor.FileSystemAccess\n```\n## Add to service collection\nAn easy way to make the service available in all your pages is by registering it in the `IServiceCollection` so that it can be dependency injected in the pages that need it. This is done in `Program.cs` by adding the following before you build the host and run it.\n```csharp\nvar builder = WebAssemblyHostBuilder.CreateDefault(args);\nbuilder.RootComponents.Add\u003cApp\u003e(\"#app\");\nbuilder.RootComponents.Add\u003cHeadOutlet\u003e(\"head::after\");\n\n// Other services are added.\n\nbuilder.Services.AddFileSystemAccessService();\n\nawait builder.Build().RunAsync();\n```\n## Inject in page\nThen the service can be injected in a page like so:\n```razor\n@inject IFileSystemAccessService FileSystemAccessService;\n```\nThen you can use `IFileSystemAccessService` to open one of the three dialogs available in the FileSystemAccess API like this:\n```razor\n\u003cbutton @onclick=\"OpenAndReadFile\"\u003eOpen File Picker for Single File and Read\u003c/button\u003e\n\u003cbr /\u003e\n@Text\n\n@code {\n    private string Text = \"\";\n\n    private async Task OpenAndReadFile()\n    {\n        FileSystemFileHandle? fileHandle = null;\n        try\n        {\n            OpenFilePickerOptionsStartInWellKnownDirectory options = new()\n                {\n                    Multiple = false,\n                    StartIn = WellKnownDirectory.Downloads\n                };\n            var fileHandles = await FileSystemAccessService.ShowOpenFilePickerAsync(options);\n            fileHandle = fileHandles.Single();\n        }\n        catch (JSException ex)\n        {\n            // Handle Exception or cancelation of File Access prompt\n            Console.WriteLine(ex);\n        }\n        finally\n        {\n            if (fileHandle is not null)\n            {\n                var file = await fileHandle.GetFileAsync();\n                Text = await file.TextAsync();\n                StateHasChanged();\n            }\n        }\n    }\n}\n```\n\n# Issues\nFeel free to open issues on the repository if you find any errors with the package or have wishes for features.\n\nA known issue is that using Streams to stream large amount of data in Blazor Server is not supported.\n\n# Related repositories\nThis project uses the *Blazor.FileSystem* package to return rich `FileSystemHandle`s both `FileSystemFileHande`s and `FileSystemDirectoryHandle`s.\n- https://github.com/KristofferStrube/Blazor.FileSystem\n\n# Related articles\nThis repository was build with inspiration and help from the following series of articles:\n\n- [Wrapping JavaScript libraries in Blazor WebAssembly/WASM](https://blog.elmah.io/wrapping-javascript-libraries-in-blazor-webassembly-wasm/)\n- [Call anonymous C# functions from JS in Blazor WASM](https://blog.elmah.io/call-anonymous-c-functions-from-js-in-blazor-wasm/)\n- [Using JS Object References in Blazor WASM to wrap JS libraries](https://blog.elmah.io/using-js-object-references-in-blazor-wasm-to-wrap-js-libraries/)\n- [Blazor WASM 404 error and fix for GitHub Pages](https://blog.elmah.io/blazor-wasm-404-error-and-fix-for-github-pages/)\n- [How to fix Blazor WASM base path problems](https://blog.elmah.io/how-to-fix-blazor-wasm-base-path-problems/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferstrube%2Fblazor.filesystemaccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristofferstrube%2Fblazor.filesystemaccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferstrube%2Fblazor.filesystemaccess/lists"}