70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
import _extends from 'babel-runtime/helpers/extends';
|
|
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
|
import _createClass from 'babel-runtime/helpers/createClass';
|
|
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
|
import _inherits from 'babel-runtime/helpers/inherits';
|
|
/* eslint react/prop-types:0 */
|
|
import React, { Component } from 'react';
|
|
import AjaxUpload from './AjaxUploader';
|
|
|
|
function empty() {}
|
|
|
|
var Upload = function (_Component) {
|
|
_inherits(Upload, _Component);
|
|
|
|
function Upload() {
|
|
var _ref;
|
|
|
|
var _temp, _this, _ret;
|
|
|
|
_classCallCheck(this, Upload);
|
|
|
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Upload.__proto__ || Object.getPrototypeOf(Upload)).call.apply(_ref, [this].concat(args))), _this), _this.saveUploader = function (node) {
|
|
_this.uploader = node;
|
|
}, _temp), _possibleConstructorReturn(_this, _ret);
|
|
}
|
|
|
|
_createClass(Upload, [{
|
|
key: 'componentDidMount',
|
|
value: function componentDidMount() {
|
|
this.props.onReady();
|
|
}
|
|
}, {
|
|
key: 'abort',
|
|
value: function abort(file) {
|
|
this.uploader.abort(file);
|
|
}
|
|
}, {
|
|
key: 'render',
|
|
value: function render() {
|
|
return React.createElement(AjaxUpload, _extends({}, this.props, { ref: this.saveUploader }));
|
|
}
|
|
}]);
|
|
|
|
return Upload;
|
|
}(Component);
|
|
|
|
Upload.defaultProps = {
|
|
component: 'span',
|
|
prefixCls: 'rc-upload',
|
|
data: {},
|
|
headers: {},
|
|
name: 'file',
|
|
multipart: false,
|
|
onReady: empty,
|
|
onStart: empty,
|
|
onError: empty,
|
|
onSuccess: empty,
|
|
multiple: false,
|
|
beforeUpload: null,
|
|
customRequest: null,
|
|
withCredentials: false,
|
|
openFileDialogOnClick: true
|
|
};
|
|
|
|
|
|
export default Upload; |