How to create a downloadable zip file with nodejs? - node.js

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:
Generate a text file
Have user upload csv
Zip the two together
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!

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!

Related

NodeJS - Compile markdown into pdf (from a string in memory) and download it on web page

I'm developing a web page. I want to create an option to generate a .pdf file and allow the user to download it.
Currently I'm using jsPDF but I'm finding it very hard to properly format the document.
I was hoping to find a new way of building it in markdown format, compile it and then download it.
Is there a way that I can do this, in node.js, where say, I have a string in memory (which is the markdown text format), compile that into a pdf and then download it from the page?
I haven't found any package that really does this, if you know, feel free to just let me know which one can achieve this and I'll figure it out.
For such a thing, I recommend building your .pdf file first a HTML file, so you could edit it easily (hardcoded or dynamicaly)
then convert your html file to .pdf file.
there is alot of packages to do this
have a closer look on this package
https://www.npmjs.com/package/html-pdf-node

Acumatica - Attachments File Extension Filter

Good Day!
I am uploading some files in form as attachments and I am trying to filter the uploaded file extensions. But I am not getting the exact solution for this.
Is there any way to filter the extensions of the files being uploaded in file attachments?
Thank you so much for the help.
If you mean blocking file upload based on the extension you can do so in File Upload Preference Screen (SM202550):
If you mean the filter for the native open file dialog. It seems hardcoded for a handful of common web files and I don't think it can be changed easily.
If you mean the file upload dialog grid, unlike most grids in the system it is not filterable through the column headers:
Maybe the Search in Files page (SM202520) is what you're looking for. You can search files based on extension here:

How to allow only pdf when uploading file in nodejs without using .extension?

I need to restrict DOC,DOCX,JPEG,JPG and other formats and allow only pdf files in nodejs without using . Extension
For example a file name called demo.jpeg and I edit as demo.pdf and I am trying to upload means now my code will allows but I want to restrict that file
what I can do?
You can use magic numbers for it: https://www.npmjs.com/package/magic-number

Retrieve contents of a ZIP file on SharePoint without downloading it

I have written a bit of automated code that checks a SharePoint site and looks for a ZIP file (lets call it doc.zip). If doc.zip is found, it downloads it, and then checks for a file (say target.docx). doc.zip is about 300MB, and so I want to only download where necessary.
What I would like to know is that given SharePoint has some ZIP search capability, is it possible to write code using CSOM (c#) to find doc.zip, and then run some code to retrieve the contents of doc.zip without downloading it.
Just to re-iterate, I am comfortable with searching for files in a folder on SP, downloading the file, and unpacking zip entries. What I need is to retrieve a ZIP files content on SP without downloading it.
E.g. is there a SP command:
cxt.Load(SomeZipFileQuery);
cxt.ExecuteQuery();
Thanks in advance.
This capability is not available. I do like the idea. Having the ability to "parse" zip files on the server side and then download the relevant bits would be ideal. Perhaps raise this on uservoice to see if others also find this us https://sharepoint.uservoice.com
Ok, I have proven yet again that stubbornness will prevail.
I have figured out that if I use the /_api/search?query='myfile.zip' web REST API to search for my file, this search will also match ZIP files that contain the file I need. And it works perfectly.
Of course there is added (pain) of parsing an XML response, but it works very nicely for my code example.
At least if someone is looking for this solution here it is. I wont bore anyone with code, as the /_api/search has probably been done to death already on other threads.

Options for Parsing Excel Files in ExtJS

I'm having a very hard time accomplishing my main goal: extracting data from an xlsx excel file
I'm running ExtJS + node.js, and I see two options:
Use this XLSX.js framework to convert the base64 string into js object-representations of xlsx worksheets for me to use. Problem is, I have no idea how to get a base64 string from an xlsx file..
Upload the xlsx file to the server, do the conversions there using node-xlsx, the send the object-representations back ala json. Having lots of difficulties here since ExtJS doesn't use real AJAX for file uploads so I don't know how to send the results back..
Has anyone had experience with this or could advise a solution? Having lots of trouble..
Number two is going to be the better option IMO. You can take a look at the FileUploadField control - there is a good example on submitting the Form that will upload the file to the server: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.File
From there you can parse and return the json.
Since we struggled with exactly the same issue, we created a front-end XLS(X) and CSV import and export tool that you can use in ExtJS 4 applications with a few lines of code. The user just drags the file on the grid and done. We just launched it, here is a description of the problematic in dealing with files and the solution: http://2gears.com/2014/08/ext-js-excel-import-export-easy/
Hope it helps.

Resources