Skip to content
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

Not able to read local file in WASM .NET Core layer #126

Closed
geetamshukla opened this issue May 7, 2024 · 2 comments
Closed

Not able to read local file in WASM .NET Core layer #126

geetamshukla opened this issue May 7, 2024 · 2 comments

Comments

@geetamshukla
Copy link

I have developed a chrome extension using WASM and able to set bidirectional communication meaning I am able to call .NET Core function from JavaScript lib and JavaScript functions from WASM Dlls .

Now , I have a file URL which I want to download and then read the content in .NET Core layer . I have tried multiple ways but unable to achieve it in Blazor.BrowserExtension .

I am able to download a file in user's download folder and want to read the file from there not sure how we can achieve it as whatever file location I hardcode and pass it to WASM Dlls it always gives null as location .

@mingyaulee can u suggest a way by which we can read a file from file system ?

@mingyaulee
Copy link
Owner

Extensions run in a sanboxed environment and you have full access to the files that are packaged together in the extension, but accessing files outside of it is is considered risky for the browsers to implement. Accessing to these files require explicit permission granting by the user when installing the extension and typically only grants access to a very small scope.

If you have a file URL, I would suggest passing that to the .Net code so that it can be downloaded and processed directly as a Stream without going through the user's file system, that is if you don't need to write to the file system.

As far as I know, if you need to read and/or write files there is no capability native to extensions, so the only way to do that is by using the standard JavaScript FileSystem API or the non-standard File System Access API if you target only chromium based browsers.

@mingyaulee
Copy link
Owner

Closed due to inactivity

@mingyaulee mingyaulee closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants