{"size": 1613, "ext": "js", "max_stars_repo_path": "src/components/FileUpload.js", "max_stars_repo_name": "TianqiCS/Chat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/FileUpload.js", "max_issues_repo_name": "TianqiCS/Chat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/FileUpload.js", "max_forks_repo_name": "TianqiCS/Chat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.6274509804, "max_line_length": 116, "alphanum_fraction": 0.4773713577}

import React from 'react';

import {
    Upload, message, Button, Icon,
} from 'antd';

class FileUpload extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        let files = this.props.files;
        const Dragger = Upload.Dragger;
        const props = {
            name: 'file',
            multiple: true,
            action: 'http://vanillacraft.cn:8001/upload',

            onChange(info) {
                const status = info.file.status;
                if (status !== 'uploading') {
                    console.log(info.file, info.fileList);
                }
                if (status === 'done') {
                    message.success(`${info.file.name} file uploaded successfully.`);
                    files.push(info.file.name)
                }
                else if (status === 'removed') {
                   files.splice( files.indexOf(info.file.name), 1 );
                }
                else if (status === 'error') {
                    message.error(`${info.file.name} file upload failed.`);
                }
            },
        };

        return (
            <Dragger {...props}>
                <p className="ant-upload-drag-icon">
                    <Icon type="inbox"/>
                </p>
                <p className="ant-upload-text">Click or drag file to this area to upload</p>
                <p className="ant-upload-hint">Support for a single or bulk upload. Strictly prohibit from uploading
                    company data or other band files</p>
            </Dragger>
        );
    }
}
export default FileUpload;