#Open a large number of images + txt with file picker + accessible to front end?
1 messages · Page 1 of 1 (latest)
Tauri's open dialog API is probably the file picker you're looking for; the built-in one only works in certain contexts. The picked files will be automatically added to the allowed scope. Then you can use the readBinaryFile fs API to read the file.
I managed to get it to work with just open ... Is that expected 
(I have both the images displaying and the text contents loading into the app, no use of readBinaryFile)
Yep. The open API modifies the allowed scope to include anything the user selects.
Out of curiosity is there a way that Tauri will allow me to read the files under a directory/folder I select? I have not been able to get it
Currently only works by opening the folder and ctrl + a
directory: true
Mhmm tried that
Probably a skill issue then
(on my part)
Ill give it another shot once I write the function to save the txt file contents back to disk 🙂
On Windows, even if you select a file, a directory dialog will return the selected directory or the current one if the selection is empty or not a directory.
Oh. Is there no way to have both, was looking for the file picker to be able to spit out either the list of files directly selected or all files (even in subfolders) if I select a directory
Ive only been able to get one or the other working so far.
You would have to make your own, unfortunately. Windows only provides an API for one or the other.
Alternatively, you could have two buttons instead of one and have the user decide.
Windows ™️
So I am going to have to somehow recognise when a directory is returned (maybe if array len is 1 and no file extensions in the path provided?), then try to recursively get paths of all files underneath it
Ah wait.
The picker straight up wont let me select a folder anyway
Yep.
™️
And I cant support dragging files in because I had to disable "fileDropEnabled"
😦
Uh is it all possible to replace the windows picker and if so how difficult would that be on a scale of 1 to 10?
You could spawn another window that impersonates a file picker; that would be about 7 on a difficulty scale to do it properly and securely.
re: securely
What are the concerns I need to think about there? This is meant to be a local only app, it should almost never be used to handle any PII, financial or even remotely personal stuff. Its just a dataset captioning application
(For diffusion based datasets, trying to make one that is much nicer to use when you need to manually caption and reduce friction)
Will be FOSS.
The main concern for security would be if your software can be used by malware to gain additional function.
So that would be if I gave it far too permissive scope
and user opened a malicious file > bam
right?
Well.. 😆
So it's more about the malware being able to interface with your program without the user being present.
Hmm. My only inputs are file dialog, I have no need for internet connectivity at this stage either. Only output is writing to the exact same path selected via dialog.
You basically want to make sure you only list the files and don't execute them.
Gotcha
Are you comfortable writing Rust code?
I am not unfortunately.
Because you're going to have to unless you give Tauri the most permissive scope: **.
Not doing the most permissive scope.
No way lol.
Ill put this down as a feature for next cycle, will investigate once I have everything else implemented
Users will just have to workaround the click folder + ctrl A
or hell. I never fix it 😆
If I may ask one more thing... Before loading the text image pairs I need to do at least one thing, unsure where I should process it + performance concern.
- I need to assign categories to the tokens, there could be thousands of txt files that I need to assess for exact match or contains and assign categories, should I consider biting the bullet and writing some function to do it in rust? (and somehow pass the value to a svelte store)
- I am concerned about loading in thousands of images into the app. Would it be better to write some rust function the (somehow) creates low res compressed webp thumbnails, or should I just try to take advantage of scroll and lazy-loading?
Oh just realised I should ping so you see it (and if you so choose to respond that is) @oblique lotus