Is it possible to display image directly from disk using absolute path or something else? #7145
-
I want to display image from disk. I know that we can read the image file as binary with But this is inefficient if the image is large or there are many images. Is there a way to display image direct from disk like this
(this didn't work for me, it looks for image at Or some other more efficient methods? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
The "tauri way" would be to use the asset protocol via https://tauri.app/v1/api/js/tauri/#convertfilesrc. It doesn't use the same IPC the fs api uses and should be much faster. |
Beta Was this translation helpful? Give feedback.
-
This is not really an answer, but just for your information. However it still wont work because it seems that Tauri (or any other frameworks really) prevents your app from loading images outside of it's working directory. I've been trying to do similar things but have been getting the error "Not allowed to load local resource" on the file. |
Beta Was this translation helpful? Give feedback.
-
You legend! I just stalked one of your projects to find the exact bit I needed...
|
Beta Was this translation helpful? Give feedback.
-
Thanks @FabianLars, @Wind-Explorer! Got things working, pulling from the Public directory (macOS). Building a Vue/Pinia app for home movie server and the same searchable/filterable 'database' is on two computers. DB is file-based, with the movie posters next to that. All i'll have to do is create a new json file for adding another movie, along with the poster. Don't have to update the app every time. Nice! |
Beta Was this translation helpful? Give feedback.
The "tauri way" would be to use the asset protocol via https://tauri.app/v1/api/js/tauri/#convertfilesrc. It doesn't use the same IPC the fs api uses and should be much faster.