Thursday, 12 July 2018

express res.download serving up 0 byte files

res.download is serving up the file but once downloaded it is 0 bytes? Any ideas?

app.get('/download', function(req, res) {
    console.log("download");
    console.log(req.query.fileID);
    fileDownload(req.query.fileID, function(rep){
        if(rep.success){
              console.log("Serving File to User, File: " + rep.data);
              res.download(__dirname +  "/" + rep.data, rep.data)   

        }else{
            console.log(res);
        }
    });
})

A ls on the folder shows the file is there ready for download, the names are correct and all on download box that browser displays but download is always 0 bytes in size.

A check on the file from file file download shoes yes it is there and yes its all good.



from express res.download serving up 0 byte files

No comments:

Post a Comment