#Open a large number of images + txt with file picker + accessible to front end?

1 messages · Page 1 of 1 (latest)

cursive grove
#

I want to be able to select a directory with the file picker and the front-end has access to them (Both a full size preview and thumbnail). I spent many many hours last night and I am too ashamed to share the code, suffice to say it didn't work. I tried FS, allowscopes etc

#

Open a large number of images + txt with file picker + accessible to front end?

oblique lotus
cursive grove
#

I managed to get it to work with just open ... Is that expected harold

#

(I have both the images displaying and the text contents loading into the app, no use of readBinaryFile)

oblique lotus
#

Yep. The open API modifies the allowed scope to include anything the user selects.

cursive grove
#

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

oblique lotus
#

directory: true

cursive grove
#

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 🙂

oblique lotus
#

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.

cursive grove
#

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.

oblique lotus
#

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.

cursive grove
#

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

oblique lotus
#

Yep.

cursive grove
#

Opens it up.

#

Fuck.

oblique lotus
#

windows™️

cursive grove
#

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?

oblique lotus
#

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.

cursive grove
#

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.

oblique lotus
#

The main concern for security would be if your software can be used by malware to gain additional function.

cursive grove
#

So that would be if I gave it far too permissive scope

#

and user opened a malicious file > bam

#

right?

oblique lotus
#

Yep.

#

But user error is beyond the scope of security.

cursive grove
#

Well.. 😆

oblique lotus
#

So it's more about the malware being able to interface with your program without the user being present.

cursive grove
#

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.

oblique lotus
#

You basically want to make sure you only list the files and don't execute them.

cursive grove
#

Gotcha

oblique lotus
#

Are you comfortable writing Rust code?

cursive grove
#

I am not unfortunately.

oblique lotus
#

Because you're going to have to unless you give Tauri the most permissive scope: **.

cursive grove
#

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 😆

cursive grove
#

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.

  1. 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)
  2. 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