CSFileDownloadBackend
Description:
Backend implementation for https://www.npmjs.com/package/cs_file_downloads_frontend
How to use:
Install:
npm i cs_file_downloads_backend
Import to your module:
var ChunkedDownload = require('cs_file_downloads_backend/chunkedDownload');
Create new instance:
var chunkedDownload = new ChunkedDownload();
2 Get functions:
// checks if file exists on server.// if exists sends size of file else sends -1app.get('/files', function(req, res) { chunkedDownload.get(req, function(size) { res.send({size}); });});
// request for a single chunk// sends back base 64 encoded chunks, name of file, // size of chunk, and the number of chunkapp.get('/file', function(req, res) { chunkedDownload.download(req, function(b64, fileName, chunkSize, chunkNumber) { res.send({b64, fileName, chunkSize, chunkNumber}); });});
See example:
See example here: https://github.com/cloverstudio/CSFileDownloadBackend