
The final solution I came up with is: download all the files to the browser and zip them there. My clients won’t mind if they wait for a few more seconds, or spend some extra MB of RAM on their laptop.


It’s great if we can shift some computing to frontend and reduce the cost for the infrastructure. I want to save costs for my infrastructure.If everything is handled at the backend, I need to find an additional approach to report status to the frontend. I love to put a progress bar on the website. It’s very hard to track processes on the client-side.Since my backend is a single-thread process, this operation can block other requests for a while and may get timed out during this time. Generating a zip file takes a long time.With the approach above, I need to redo the whole thing all the time, it’s not really efficient. So, while the Zip file itself is not likely reusable, the single files do. Although the Zip files are different sets of reports, it’s very likely that most of the individual reports have been generated by an earlier request. It cannot utilize the feature I had already built.They will take time to process and require a lot of effort coding, testing, and maintenance later on. I need to consider generating all files per request or combining between reusing existing files and generating new ones.

The logic to generate a zip file is quite complicated.Instead of individual files, I needed to download a zip file containing hundreds of reports. If a user orders the same thing, the backend will return the URL of the existing file.Ī few days ago, I had a new requirement.

Since generating a report takes a while, the output files are stored and the server caches their URLs by request params. For each request, our backend will generate a report, upload it to Amazon S3 storage, and return its URL to the client. Here is the code for download file function.I recently worked on a side project, which generates reports per user’s request. I am able to download the file stored on FTP by using basic-ftp package. Node.js app should not store any file uploaded from it and download from it.ģ: Client: A user how will upload or download a file to FTP server by using Node.js app. Node.js app have no collection of files stored on FTP. No direct access.Ģ: Node.js: Provides an API to interact with FTP server.
