KristofferStrube / Blazor.FileSystemAccess

A Blazor wrapper for the File System Access browser API.
https://kristofferstrube.github.io/Blazor.FileSystemAccess/
MIT License
327 stars 39 forks source link

Added support to write byte arrays. #9

Closed nzmangan closed 2 years ago

nzmangan commented 2 years ago

Added support to write byte arrays.

Converting byte array to string using stream reader - readToEnd will convert to byte array to string but it will also add UTF8(?) encoding. This causes the file saved not to contain the same bytes as "just" writing the raw byte array.

KristofferStrube commented 2 years ago

Hey @nzmangan, Great PR. 😊

I had missed that ArrayBuffer is a part of FileSystemWriteChunkType.

Could you potentially add a sample of using this overload or edit an existing to use this? One place that would be easy to use it is here: InputFileExample.razor where I currently convert to string first.

nzmangan commented 2 years ago

Example updated as requested.

KristofferStrube commented 2 years ago

Thanks for the contribution Magnus. :) I will make a Release to Nuget with the feature later today.