并行下载时 React-Native-fs 下载速度慢

问题描述

我在下载单个文件时速度很快。但是当我开始下载多个文件时,下载速度太差了。我开始这是我的代码

import { DocumentDirectoryPath,exists,mkdir,readDir,downloadFile,writeFile,readFile} from 'react-native-fs'
function download(fileId,fileUrl){ 
    let path = DocumentDirectoryPath+'/'+'Learning/'+fileId; 
          let zipPath =DocumentDirectoryPath+'/'+'Learning/'+fileId+"/Compressed.zip";
          let exist = await exists(path);
          if(exist === false){
    
            await  mkdir(path);
            console.log("path created",path)
          }
          
    //alert("======"+fileUrl)
        const downloadPromise = downloadFile({
          fromUrl: fileUrl,toFile: zipPath,progress: function ({contentLength,jobId,bytesWritten}) {
            if (jobId === downloadPromise.jobId) {
              progressCallback(bytesWritten / contentLength);
              console.log( "\b",bytesWritten / contentLength)
            }
          },});
        const downloadResult = await downloadPromise.promise;}

然后像这样开始多次下载:

let files = [{url: "https//....",id: "y6HS6"},{url: "https//....",id: "y6HghhS6"}]
files.map(item =>{
download(item.id,item.url)
})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)