Feature request: Accessing webkitRelativePath and class extensibility
First, thank you for your outstanding work on the Blazor.FileAPI library. It's truly a pleasure to use.
I'm working on a project that requires access to the webkitRelativePath property of the File object.
As the File class has an internal constructor, I've found that I cannot inherit from it to extend its functionality. This design forces me to use JSRuntime.InvokeAsync with the "getAttribute" helper to retrieve this simple property, which feels unnecessarily verbose for this use case.
Would you consider adding a public method to the IJSWrapper interface, or an extension method, that provides a more direct way to access common properties? For example, something like a GetPropertyAsync<T>() method. Or perhaps by adding a GetHelperReferenceAsync method to the BaseJSWrapper/IJSWrapper class?
This would greatly improve the API's usability and allow external classes to extend wrappers more elegantly.
Thank you for your time and for considering my request.
Hey @Enfis, thanks for the kind words! π
In the latest version of the package the constructor for File is actually protected instead of internal as I had also found that it was difficult to extend.
I imagine that you might be using the package together with some of my other packages, if you could share which version you are using of them then I might be able to help more. Iβm currently working on upgrading Blazor.FileSystem to use the latest version of this library actually.
Hello, and thank you for the fast reply!
My sincerest apologies; you are absolutely right.
It turns out there was a "lowest applicable version" issue with my NuGet packages: my project was inadvertently referencing version 0.3.0 through a transient dependency instead of the latest one. I have now resolved the issue.
Thank you again for your patience and for your work on these libraries.
It might not be possible to update it directly (even though it is within the same major version) as I made a binary-breaking change in Blazor.WebIDL some time ago. But Iβm working on updating the file system and file system access packages to the newest version. I will update you here once that is done. Sorry for the inconvenience.
Thanks for the feedback! I'm still learning Blazor and havenβt reached that part of the code yet. It would be great if a Blob/File could be encapsulated in a System.IO.Stream for both reading and writing - at least in WebAssembly mode.
Do you think I should ask this in a new thread?
It has actually been requested before in #2 but if you would leave a comment there describing your use case/scenario then that would be helpful to track interest in the feature. π
Hello again. I apologize if this is an oversight, but it appears the 'InProcess' version cannot be extended. The IJSInProcessObjectReference (inProcessHelper) constructor parameter is not publicly available outside of your assembly (canonically).
I usually keep the extensions for my helpers internal yeah, but if you need it, then it's pretty simple: https://github.com/KristofferStrube/Blazor.FileAPI/blob/main/src/KristofferStrube.Blazor.FileAPI/Extensions/IJSRuntimeExtensions.cs#L12
Hello, thanks for the clarification. I've also noticed the JavaScript code is quite simple. For a more complete and robust API, would you consider integrating the webkitRelativePath property directly into your library's File(InProcess) class? This would be very helpful for developers building directory pickers.
Hey @Enfis, it seems like it is not defined in the File API, but that they plan to introduce it there if the File and Directory Entries API graduates to a real standard. So I don't think I will add it yet until/if it is ever added to the File API.
Hello, thank you again for putting me on the right track ππ I'm still a novice in the JavaScript/Blazor world, unfortunately π₯²
@Enfis you are doing good! Keep staying curious. πͺ