1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4 | import _inherits from 'babel-runtime/helpers/inherits';
|
5 | import React from 'react';
|
6 | import Html5Uploader from './html5-uploader';
|
7 | import IframeUploader from './iframe-uploader';
|
8 |
|
9 | var Uploader = function (_React$Component) {
|
10 | _inherits(Uploader, _React$Component);
|
11 |
|
12 | function Uploader() {
|
13 | var _temp, _this, _ret;
|
14 |
|
15 | _classCallCheck(this, Uploader);
|
16 |
|
17 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
18 | args[_key] = arguments[_key];
|
19 | }
|
20 |
|
21 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
|
22 | Component: Html5Uploader
|
23 | }, _this.saveUploaderRef = function (ref) {
|
24 | _this.uploaderRef = ref;
|
25 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
26 | }
|
27 |
|
28 | Uploader.prototype.componentDidMount = function componentDidMount() {
|
29 | if (typeof File === 'undefined') {
|
30 |
|
31 | this.setState({
|
32 | Component: IframeUploader
|
33 | });
|
34 | }
|
35 | };
|
36 |
|
37 | Uploader.prototype.abort = function abort(file) {
|
38 | this.uploaderRef.abort(file);
|
39 | };
|
40 |
|
41 | Uploader.prototype.startUpload = function startUpload(files) {
|
42 | this.uploaderRef.startUpload(files);
|
43 | };
|
44 |
|
45 | Uploader.prototype.render = function render() {
|
46 | var Uploader = this.state.Component;
|
47 | return React.createElement(Uploader, _extends({}, this.props, { ref: this.saveUploaderRef }));
|
48 | };
|
49 |
|
50 | return Uploader;
|
51 | }(React.Component);
|
52 |
|
53 | Uploader.displayName = 'Uploader';
|
54 | export { Uploader as default }; |
\ | No newline at end of file |