3

I'm currently using electron with nodejs and then using the plugin browserify to make it compatible online to make a website. One of the things I want to do is to have the user upload a file (csv), combine it with a text file that I generate, zip the two up, and then give them a "download zip" option that they can use to download the zip I generated. I would also want all of this to occur client-side.

What I need to happen is again:

  1. Generate a text file
  2. Have user upload csv
  3. Zip the two together
  4. Give the user a link to download zip

All client-side.

I've already searched online for methods to do this, but all the ways to implement a download link that I found either require the file to be a text file, or use fs/express or some other plugins that don't seem to work with browserify.

If what I'm asking for isn't possible, let me know so I don't waste time!

Thanks in advance!

5
  • 1
    Have a look at stuk.github.io/jszip. You can create a .zip file with folders and files (file content is a string parameter) with the help of that library. Seems like that should do the trick. Commented Jan 11, 2016 at 8:13
  • @leroydev, Would the string zip files be converted to the .zip file format correctly? Commented Jan 11, 2016 at 21:46
  • what do you mean? If you're asking if it'll save correctly as a .zip file, you can use github.com/eligrey/FileSaver.js for that. Commented Jan 11, 2016 at 22:41
  • @leroydev, I'm using it along with browerserify, this is all happening online. I'm not sure I can directly save it onto their computer, I need to provide them a download link. Commented Jan 11, 2016 at 23:41
  • @leroydev, nevermind, I got it to work Commented Jan 12, 2016 at 0:52

1 Answer 1

1

Thanks to leroydev's response, I was able to generate the zip file using jszip, upload the csv using a form with input type="file" accept=".csv", read the file using FileReader, and then finally save the zipped file by using FileSaver with jvsteiner's solution.

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.