Upload.js 1.39 KB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";

/* eslint react/prop-types:0 */
import React, { Component } from 'react';
import AjaxUpload from './AjaxUploader';

function empty() {}

var Upload = /*#__PURE__*/function (_Component) {
  _inherits(Upload, _Component);

  var _super = _createSuper(Upload);

  function Upload() {
    var _this;

    _classCallCheck(this, Upload);

    _this = _super.apply(this, arguments);

    _this.saveUploader = function (node) {
      _this.uploader = node;
    };

    return _this;
  }

  _createClass(Upload, [{
    key: "abort",
    value: function abort(file) {
      this.uploader.abort(file);
    }
  }, {
    key: "render",
    value: function render() {
      return React.createElement(AjaxUpload, Object.assign({}, this.props, {
        ref: this.saveUploader
      }));
    }
  }]);

  return Upload;
}(Component);

Upload.defaultProps = {
  component: 'span',
  prefixCls: 'rc-upload',
  data: {},
  headers: {},
  name: 'file',
  multipart: false,
  onStart: empty,
  onError: empty,
  onSuccess: empty,
  multiple: false,
  beforeUpload: null,
  customRequest: null,
  withCredentials: false,
  openFileDialogOnClick: true
};
export default Upload;