How to save input results (webkitdirectory) for later use?

I would like to allow the user to select the directory (in which I am parsing some text files) and store the result(List<File>) in the PERSISTENT repository on the same client, so that when the user returns, there is no need to reselect the same directory.

During the session, selecting a directory (via <input webkitdirectory="..." /> ), and then accessing the directory and analyzing the file already works fine, but I donโ€™t know what data I will save to get it later. I tried using window.webkitResolveLocalFileSystemURL() but was not successful so far ... any idea?

+4
source share
1 answer

So you are using something like:

 <input type="file" id="file-input" webkitdirectory="" directory=""> 

This allows the user to download the directory. Roughly speaking, here is the code for downloading the list of downloaded files:

 query("#file-input").on.change.add((e) { print(e.target.files); }); 

It looks like you already understood this part.

Indeed, you just get a list of files. I looked at e.target, and I donโ€™t think that there was anything related to the directory itself. For example, I donโ€™t see anything in the directory name, and itโ€™s not as if you suddenly had write access to this directory. You also cannot download files from this directory the next time the user loads the page without re-selecting the directory.

However, you can download files from this directory and save a copy of these files locally using local file storage.

See also:

By the way, I know that I could not achieve exactly what you wanted, but if you approve of my answer, please accept it. My boss promised to buy me a puppy if I answer 100 questions about stack overflow;)

+4
source

Source: https://habr.com/ru/post/1441590/


All Articles