rc-upload
Advanced tools
Comparing version 1.2.3 to 1.2.4-beta1
@@ -5,2 +5,6 @@ 'use strict'; | ||
function uid() { | ||
return Math.random().toString().slice(2); | ||
} | ||
var AjaxUploader = React.createClass({ | ||
@@ -35,3 +39,5 @@ displayName: 'AjaxUploader', | ||
file.uid = uid(); | ||
var props = this.props; | ||
props.onStart(file); | ||
var req = request.post(props.action).attach(props.name, file, file.name); | ||
@@ -43,6 +49,10 @@ | ||
req.on('progress', props.onProgress); | ||
var progress = function progress(e) { | ||
props.onProgress(e, file); | ||
}; | ||
req.on('progress', progress); | ||
req.end(function (err, ret) { | ||
req.off('progress', props.onProgress); | ||
req.off('progress', progress); | ||
if (err || ret.status !== 200) { | ||
@@ -49,0 +59,0 @@ var message = err ? err.message : ret.text; |
@@ -81,2 +81,3 @@ 'use strict'; | ||
this.file = e.target.files[0]; | ||
this.props.onStart(this.file); | ||
React.findDOMNode(this.refs.form).submit(); | ||
@@ -83,0 +84,0 @@ }, |
@@ -18,2 +18,3 @@ 'use strict'; | ||
onProgress: PropTypes.func, | ||
onStart: PropTypes.func, | ||
data: PropTypes.object, | ||
@@ -29,2 +30,3 @@ accept: PropTypes.string | ||
onProgress: empty, | ||
onStart: empty, | ||
onError: empty, | ||
@@ -31,0 +33,0 @@ onSuccess: empty |
{ | ||
"name": "rc-upload", | ||
"version": "1.2.3", | ||
"version": "1.2.4-beta1", | ||
"description": "upload ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -54,2 +54,3 @@ # rc-upload | ||
|accept | string | | input accept attribute | | ||
|onStart | function| | start upload file | | ||
|onError| function| | error callback | | ||
@@ -56,0 +57,0 @@ | onSuccess | function | | success callback | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8758
215
62
1