Is it possible to zip up and send a local (to the app) directory without requiring the user to select one?

69
March 03, 2021, at 6:10 PM

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.

READ ALSO
Check if Column exceeding specific value and replace

Check if Column exceeding specific value and replace

I use the long list of codes similar to below codes, to check data frame with multiple columns

42
Radio and checkbox cannot be checked when inside BootStrap Modal

Radio and checkbox cannot be checked when inside BootStrap Modal

I have a bootstrap modal that needs to have both radio┬┤s and checkboxes, and when I place the below code outside the Modal they work as expected, but as soon as I move them inside the modal I am not able to check/choose themI am using Bootstrap v

46
linear-gradient over Gatsby-Background-Image

linear-gradient over Gatsby-Background-Image

I have an image that I reference from with a Graphql query in my codeOver this image I want to have a linear-gradient, which is located in my css module

79
Tomcat 9 class loading issue with Jaxb-impl& jaxb-runtime

Tomcat 9 class loading issue with Jaxb-impl& jaxb-runtime

Jaxb-api and jaxb-runtime has same package with same class name called RUNTIMEMODELBUILDERJAVA and same interface with same package Navigator interface

61