Skip to content

Conversation

@picotincc
Copy link

@picotincc picotincc commented Dec 26, 2016

加了一个属性去判断是否要自动上传至七牛云

propTypes: {
        onDrop: React.PropTypes.func.isRequired,
        token: React.PropTypes.string.isRequired,
        // called before upload to set callback to files
        onUpload: React.PropTypes.func,
        size: React.PropTypes.number,
        style: React.PropTypes.object,
        supportClick: React.PropTypes.bool,
        accept: React.PropTypes.string,
        multiple: React.PropTypes.bool,
        autoUpload: React.PropTypes.bool,
        // Qiniu
        uploadUrl: React.PropTypes.string,
        prefix: React.PropTypes.string,
        //props to check File Size before upload.example:'2Mb','30k'...
        maxSize:React.PropTypes.string,
    }

onDrop方法里的改动

for (var i = 0; i < maxFiles; i++) {
            if( maxSizeLimit && files[i].size > maxSizeLimit){
               console.trace && console.trace(new Error('文件大小错误!'))
                this.props.onError && this.props.onError({
                   coed:1,
                   message:'上传的文件大小超出了限制:' + this.props.maxSize
               })
            }else{
                files[i].preview = URL.createObjectURL(files[i]);
                files[i].request = this.upload(files[i]);
                if (this.props.autoUpload)
                {
                    files[i].uploadPromise = files[i].request.promise();
                }
                else
                {
                    files[i].upload = files[i].request.promise.bind(files[i].request);
                }
            }
        }

my demo

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

Successfully merging this pull request may close these issues.

1 participant