Hi All!I was wondering if any of you had a better idea on how to proceed with making multiple axios calls to download all chunks of a file, this is what I have so far.const file = require('file-system'); const fs = require('fs'); const axios = require('axios'); const file_url = 'https://ift.tt/1srKqxy' axios.get( file_url, { // params: { // ID: 12345 // }, headers: { Range: 'bytes=0-1' } }) .then((response) => { console.log('server status: ', response.status); console.log('server response: ', response.headers); fs.mkdir('downloads/', function(err) {}); fs.writeFile('downloads/example.zip', 'aaa', function(err) {}) // FileDownload(response.data); // console.log(response); // console.log(response.data); }) .catch(function (error) { console.log(error); }); My issue is:I need to make multiple axios requests, but not entirely sure how to make enough requests to download the entire file in chunks.I don't exactly understand how header-range works. Whenever I adjust it to '0-1', it still downloads all 3 bytes of the file, which is the size of the entire file.once I download the entire file in chunks do I need to do it with async await so I can stitch it back together or will it save the chunks on my drive and ill have to run it through my script to stitch it together?all help is appreciated. thank you!
Submitted September 27, 2018 at 02:54PM by ohmynano
No comments:
Post a Comment