cs_file_downloads_backend

1.0.2 • Public • Published

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 -1
app.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 chunk
app.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

Package Sidebar

Install

npm i cs_file_downloads_backend

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • mislav.clover