Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select multiple files, how to get every file's progress? #35

Open
xsawn opened this issue Jan 20, 2017 · 2 comments
Open

select multiple files, how to get every file's progress? #35

xsawn opened this issue Jan 20, 2017 · 2 comments

Comments

@xsawn
Copy link

xsawn commented Jan 20, 2017

if I select more than one file, i can get only one progress event of all the files.
then i can only get one progress bar.
i want to get every file's progress bar.

@wizard-a
Copy link

wizard-a commented Jan 21, 2017

@xxshawn 我目前能想到的方法:

  1. 你把多个文件个拆开,一个一个上传,
  2. 你可以自己去写个算法去计算多个文件当中的每一个上传进度。
       const { fileList, fileUploading } = this.state;
       if (fileUploading.length == 1) {
           let p = (progress.loaded / progress.total) * 100;
           this.onProgress(p, fileUploading[0], fileList);
           return;
       }
       if (fileUploading.length > 1) {
           let sumFileSize = 0,
               progressedSize = 0,
               nextFileProgressZero = false;
           fileUploading.forEach(file => {
               let p = 0;
               if (progress.loaded == progress.total) {
                   p = 100;
               } else if (nextFileProgressZero) {
                   p = 0;
               } else if (!nextFileProgressZero) {
                   sumFileSize += file.file.size;
                   // 处理进度 大于当前文件大小
                   if (progress.loaded - sumFileSize > 0) {
                       p = 100;
                       progressedSize += file.file.size;
                   } else {
                       p = ((progress.loaded - progressedSize) / file.file.size) * 100;
                       nextFileProgressZero = true;
                   }
               }
               this.onProgress(p, file, fileList);
           })
       }
   }

@anurodhsahu
Copy link

anurodhsahu commented Mar 12, 2017

@Jiechud Can you please be more specific? Where to write this block of code and from where we get the vale of fileList and fileUploading?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants