【发布时间】:2018-11-29 03:55:42
【问题描述】:
我可以在上传多个文件时显示一个进度百分比。如果我上传多个文件,如何分隔进度百分比?
//multi upload
fileuploadHandler = () => {
const storageRef = fire.storage().ref();
this.state.file.forEach((file) => {
storageRef
.child(`images/${file.name}`)
.put(file).then((snapshot) => {
var uploadTask = storageRef.child(`images/${file.name}`).put(file);
uploadTask.on('state_changed', (snapshot) =>{
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
var fixprogress = progress.toFixed(2);
this.setState({fixprogress});
console.log('Upload is ' + fixprogress + '% done');
})
})
});
}
这是我的按钮并显示进度百分比。
<button className="loginBtn2 loginBtn--U" onClick={this.fileuploadHandler}> Upload!</button>
uploading {this.state.fixprogress}
【问题讨论】:
标签: javascript reactjs firebase firebase-storage progress