Package Exports
- multipart-download
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (multipart-download) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
multipart-download 
Speed up download of a single file with multiple HTTP GET connections running in parallel
Class: MultipartDownload
MultipartDownload is an EventEmitter.
start(url, numOfConnections[, saveDirectory])
url<string> Url of file to be downloadednumOfConnections<number> Number of HTTP GET connections to use for performing the downloadsaveDirectory<string> Directory to save the downloaded file (Optional)
Starts the download operation from the url.
Multiple HTTP GET connections will only be used if the target server supports partial requests.
If the target server does not support partial requests, only a single HTTP GET connection will be used regardless of what the numOfConnections is set to.
If the saveDirectory parameter was provided, the downloaded file will be saved to the saveDirectory.
If the saveDirectory parameter was not provided, the downloaded file will not be saved.
Event: 'data'
data<string> | <Buffer> Chunk of data receivedoffset<number> Offset for the chunk of data received
The file being downloaded can be manually constructed and manipulated using the data and offset received.
Event: 'end'
filePath<string> Downloaded file saved path
filePath is the location of the saved file if the saveDirectory parameter was provided.
filePath will be null if the saveDirectory parameter was not provided.
Example
const os = require('os');
const MultipartDownload = require('multipart-download');
try {
new MultipartDownload()
.start('https://homepages.cae.wisc.edu/~ece533/images/cat.png', 5, os.tmpdir())
.on('data', (data, offset) => {
// manipulate data here
})
.on('end', (filePath) => {
console.log(`Downloaded file path: ${filePath}`);
});
} catch (err) {
console.log(err);
}