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

How to display the file like image and video into frontend after picking with the OpenFileDialog? #3168

Open
dunkbing opened this issue Jan 4, 2024 · 5 comments

Comments

@dunkbing
Copy link

dunkbing commented Jan 4, 2024

I want to pick a file (image, video), perform some operations on it, and then display it to the front-end. If I do the picking from the front-end, then I cannot get the file path.

@yalay
Copy link

yalay commented Jan 4, 2024

use runtime.OpenMultipleFilesDialog to pick a file

@yalay
Copy link

yalay commented Jan 4, 2024

@dunkbing
Copy link
Author

dunkbing commented Jan 4, 2024

use runtime.OpenMultipleFilesDialog to pick a file

This function only returns the selected files 😅 How do I display it on the screen?

@yalay
Copy link

yalay commented Jan 10, 2024

You mean runtime.BrowserOpenURL(f.ctx, "file://"+filePath)?

@leaanthony
Copy link
Member

Either return the whole file via the binding (probably slow) or what I'd do is setup an asset handler to return the file and then after selection of the file emit an event to load it, which will trigger the assethandler to load it.

So:

  1. Install asset handler to manage /fs/ paths
  2. Create JS event handler which listens to "fileload" events and does a fetch on "/fs/"+filename
  3. When you select a file, emit ("fileload", filename)

It's not ideal and I'd be cautious of opening your whole filesystem up so maybe configure your asset handler to process paths only in a certain sub directory

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

3 participants