I'm attempting to create an app that can access a directory in the app's directory, zip it with JSZip and send it to an API at the press of a single button.
For instance, say I have a directory "Components" in the app's directory. At the press of one button (Deploy Components) the app should zip up that directory using JSZip and send it off to an API. It seems like React cannot access its own directory short of imports, and imports do not import a directory, only a single file. What I need is the full Components directory, with all files and sub-directories (and their files and sub-directories, and so on), zipped up and punted off.
I know I could have a form and have the user upload a zip file, but this gives the user far too much freedom to upload whatever they like - they should only be able to send this Components directory (which lives with the app and can't be changed without re-deploying the app) to the API.
Does JSZip have any methods that can create a new zipped folder from a provided local directory path? Does React have any functions I can use to load a directory, rather than individual files? Does node.js provide anything I can use (I am not familiar with node.js)? In my API (written in C#) I can use things like the System.IO File and Directory static classes to do things like this, but I am not sure if it is possible with React.
Is this even remotely possible? I've spent the best part of an afternoon trying to find ways of accessing and manipulating a local directory with react and mostly drawn blanks.
Edit: I stuck this on the backburner for a while, but eventually found this answer: Need to ZIP an entire directory using Node.js and this has solved my issue.