king
2020-01-05 71b872aa44de6266a344646d0e535895620d57a7
src/tabviews/tableshare/fileupload/index.jsx
@@ -57,24 +57,25 @@
    }
  }
  shardupload = (file, shardSize, shardCount, i) => {
  shardupload = (file, shardSize, shardCount, i, fileList) => {
    let start = i * shardSize
    let end = Math.min(file.size, start + shardSize)
    let form = new FormData()
    form.append('data', file.slice(start, end)) //slice方法用于切出文件的一部分
    form.append('file', file.slice(start, end)) //slice方法用于切出文件的一部分
    form.append('RootPath', 'Content/images/upload/')
    form.append('name', file.name)
    form.append('total', shardCount)
    form.append('index', i + 1)
    if (i < shardCount) {
      i++
      Api.getFileUpload(file).then(res => {
      Api.getFileUpload(form).then(res => {
        if (res) {
          this.setState({
            percent: Math.floor(100 * (i / shardCount))
          })
          this.shardupload(file, shardSize, shardCount, i)
          this.shardupload(file, shardSize, shardCount, i, fileList)
        }
      })
    } else {
@@ -92,8 +93,8 @@
  }
  beforeUpload = (file, fileList) => {
    let shardSize = 200 * 1024 * 1024
    // console.log(file)
    let shardSize = 2 * 1024 * 1024
    // let shardSize = 3 * 1024
    if (file.size > shardSize) {
      this.setState({
@@ -101,7 +102,7 @@
        percent: 0
      })
      let shardCount = Math.ceil(file.size / shardSize)
      this.shardupload(file, shardSize, shardCount, 0)
      this.shardupload(file, shardSize, shardCount, 0, fileList)
      return false
    } else {
      return true