How to trigger Zip download on server?

On my server I am storing a base64 data url of a zip folder. When someone hits a certain server side route, I want to trigger a download of the zip file. Previously, I was using"data:application/zip;base64, " + data_url); client side to get it to work. Now I’m trying to get the download working when someone hits a particular server side route… How would I do that? I have been trying this:

Router.route('/zd/:_id', function () {
    var req = this.request;
    var res = this.response;
    var zipDownload = ZipDownloads.findOne(this.params._id);

    if (zipDownload) {
        res.writeHead(200, {'Content-Type': 'application/octet-stream',"Content-Disposition": "attachment;"});
    } else {
        res.end("This link is no longer active");


}, {where: 'server'});

However, the zip that it returns is corrupted and turns into a .zip.cpgz. I’d appreciate any help!

Maybe you need to specify the encoding when calling res.end()? Check out this SO post