Support for simultaneous multiple downloads


#1

Hi,

i would like to develop a download manager.

I looked into Electron thoroughly. I guess my only question is with using Chromium browser libs, will it limit the number of simultaneously downloads a user can do? I want to allow at least 3 simultaneous downloads in the application.

Please let me know if this can be an issue, before i start development. Thanks in advance


#2

Hi,
I have developed something similar except it’s simultaneous download.
I am downloading multiple images in one function call.

Here is code:

function downloadResourcesOffline(data){

      var imgsArr = [];

      for(var i=0;i<data.length;i++){
          var resourceName = data[i].name;
          resourceName = resourceName.replace(/-/g, '');
          
          imgsArr.push({url:data[i].url,name:resourceName});
          
      }


      var downloadImages = function(callback) {
        console.log("images length "+imgsArr.length);
          if(imgsArr.length > 0) {
              var file = imgsArr.shift();
              console.log("processing...");
              download_file_httpget('images',file.url,file.name+'.jpg').then(()=>{
                downloadImages(callback);
              })
          } else {
              callback();
          }
      }

      

      downloadImages(function() {
          console.log("....Images downloaded....");
      });
      
}

// Function to download file using HTTP.get
function download_file_httpget(folderToStore,file_url,file_name) {

    return new Promise(function(resolve,reject){

        var options = {
            host: url.parse(file_url).host,
            port: 80,
            path: url.parse(file_url).pathname
        };

        var file = fs.createWriteStream(path.join(localResourcesPath,folderToStore,file_name));

        http.get(options, function(res) {
            res.on('data', function(data) {
                file.write(data);
            }).on('end', function() {
                file.end();
                resolve('done');
            }).on('error',function(err){
                reject(err);
            });
        });

    })
    
}

Or you can visit this