Skip to content

关于fileAdded事件,返回false时的处理,以及分片优化方案的建议 #1

Closed
@xyhxyw

Description

@xyhxyw

1 监听fileAdded事件,如果返回false,文件未加入上传队列(uploader.files),但却加入了uploader.fileList中并在页面显示了出来。
期望:返回了flase,应该表示该文件不是用户需要的文件,不应该加入uploader.fileList。
uploader.js 133行,可修改为:

     var _file = new File(this, file, this)
      _file.uniqueIdentifier = uniqueIdentifier
      var ignored = this._trigger('fileAdded', _file, evt);

      if (ignored) {
        _file.uploaed = 2;
        _files.push(_file)
      }else{
        this.removeFile(_file)
        //alert(_file.name+':格式不正确')
      }

2:进行分片上传时,有时候并不需要每个分片都做一次testChunks。这样对于较大文件,会浪费很多次请求。
建议,可增加一个参数enableOnceCheck。

enableOnceCheck为true时,在文件加入上传队列时,请求一次后台(GET),获取当前文件已经上传的分片位置,并保存到_file对象中。

如_file.uploadeChunk = 10,开始上传时(uploadNextChunk),直接从第11个分片开始POST(并且此时不需要再做分片检测的GET请求)。这种方案对于大文件,可以节省大量的GET检测请求。

enableOnceCheck为false时,默认状态,依旧对每个分片进行GET检测。

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions