-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to read file bytes? #10
Comments
Hey @cityadpro, There is only implemented a limited set of wrapper methods for the I have though made it possible to call the methods you wish on the File file; // Your file
bytes[] blobAsData = await file.JSReference.InvokeAsync<byte[]>("arrayBuffer"); |
Hello @KristofferStrube, thank you very much for answering. I'll try your proposal as soon as I can. Thank you! |
Hello Kristoffer, hope you are doing well. I have the exact same requirement as cityadpro and using the code your provided we get an exception even with the simplest example of just one file trying to get its content
We added that method right below the text one in your library and call it from a file object from your library and get the following exception: Seems to not be returning a byte array at all. If we set the type to dynamic and check what we get we don't see any useful properties. Are we missing something? did you test that approach actually works? Any pointer would be great. |
Hey @mattmoll, You are right. I didn't get around to testing my recommended solution for the problem but expected that it helped as there was no response. I have dug more into the problem and found my mistake. I thought that the ArrrayBuffer was able to be serialized into a byte array as it is directly convertible to an Uint8Array. The problem is that in order to convert an ArrayBuffer into a Uint8Array we need to parse it through the constructor. We can't do that through JS Interop directly yet. This is an issue, which is tracked in dotnet/aspnetcore#31151. Instead, you would need to make a wrapper function in JS that
I have not tested the above approach but would expect it works. |
Hello,
I've been trying to use your wrapper to read recursively files in a folder structure. I need to get all bytes from every file in an array, but I cannot imagine how to do it.
Is there anyone here that knows how to get all the content of a file in an array of bytes?
Thank you!
The text was updated successfully, but these errors were encountered: