tusharmath/Multi-threaded-downloader

simple example on how to download/pause/resume a chunked download

stukennedy opened this issue · 3 comments

It would be great to see how to make a function that could be called like this

var ref = downloadFile({ url, file })

where, if the file has already started downloading it refreshes the url (to deal with time-limited links) and resumes downloading.
And it would also help to see how to pause the download using the API

pauseDownload(ref)

This would need to work for AWS Signed links (e.g. time limited) and chunked files that may not respond with filesize in the header.
Here is a URL to test with

http://s3.amazonaws.com/stukennedy.torchwood/close_credits.zip?AWSAccessKeyId=AKIAINMRPVWBZGXJIQUQ&Expires=1786921700&Signature=VyoYeKHrGMw26ZrP9EIIiuiNy70%3D

A whole year have passed since I last tried using this and couldn't... Still no simple example usage.. I just found out its Rx -based (whatever that is, which I'm not interested to know either)

I just found this and while I think that this might interesting I have no idea how to do anything with this module because there is no example whatsoever and it's quite complex to wrap my head around it.

motin commented

Same here. There is a wrapper at https://github.com/leeroybrun/node-mt-files-downloader which simplifies things and has examples, but it also mentions that it needs refactoring to work with the latest mt-downloader versions. (A more recent fork of the wrapper is found here https://github.com/Fer0x/node-mt-files-downloader)

The closest available in this lib seem to be the createDownload function at https://github.com/tusharmath/Multi-threaded-downloader/blob/master/perf/TestHelpers.js#L45 (a function which possibly previously was part of an official example according to #63)

Example usage is found at https://github.com/tusharmath/Multi-threaded-downloader/blob/master/test/integration/test.mtd.js#L42

await createDownload({
  url: 'http://localhost:3200/files/pug.jpg',
  path: path1
}).toPromise()

Imports:

import {createDownload} from 'mt-downloader/perf/TestHelpers'