rc-upload
Advanced tools
Comparing version 1.10.0 to 1.11.0
# History | ||
---- | ||
### 1.11.0 2016-05-03 | ||
- Allow all 2xx status as success status, not only 200. fix #34 | ||
- When `headers['X-Requested-With'] = null` , request do not set X-Requested-With as XMLHttpRequest , fix #33 | ||
### 1.9.0 2016-03-23 | ||
@@ -5,0 +10,0 @@ |
@@ -29,2 +29,14 @@ 'use strict'; | ||
// option { | ||
// onProgress: (event: { percent: number }): void, | ||
// onError: (event: Error, body?: Object): void, | ||
// onSuccess: (body: Object): void, | ||
// data: Object, | ||
// filename: String, | ||
// file: File, | ||
// withCredentials: Boolean, | ||
// action: String, | ||
// headers: Object, | ||
// } | ||
function upload(option) { | ||
@@ -60,3 +72,5 @@ if (typeof XMLHttpRequest === 'undefined') { | ||
xhr.onload = function onload() { | ||
if (xhr.status !== 200) { | ||
// allow success when 2xx status | ||
// see https://github.com/react-component/upload/issues/34 | ||
if (xhr.status < 200 || xhr.status >= 300) { | ||
return option.onError(getError(option, xhr), getBody(xhr)); | ||
@@ -75,6 +89,12 @@ } | ||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
var headers = option.headers || {}; | ||
// when set headers['X-Requested-With'] = null , can close default XHR header | ||
// see https://github.com/react-component/upload/issues/33 | ||
if (headers['X-Requested-With'] !== null) { | ||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | ||
} | ||
for (var h in headers) { | ||
if (headers.hasOwnProperty(h)) { | ||
if (headers.hasOwnProperty(h) && headers[h] !== null) { | ||
xhr.setRequestHeader(h, headers[h]); | ||
@@ -81,0 +101,0 @@ } |
@@ -27,3 +27,2 @@ 'use strict'; | ||
propTypes: { | ||
forceAjax: _react.PropTypes.bool, | ||
action: _react.PropTypes.string, | ||
@@ -49,3 +48,2 @@ name: _react.PropTypes.string, | ||
name: 'file', | ||
forceAjax: false, | ||
multipart: false, | ||
@@ -52,0 +50,0 @@ onProgress: empty, |
{ | ||
"name": "rc-upload", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "upload ui component for react", | ||
@@ -23,3 +23,3 @@ "keywords": [ | ||
}, | ||
"licenses": "MIT", | ||
"license": "MIT", | ||
"files": [ | ||
@@ -51,3 +51,4 @@ "lib" | ||
"react-addons-test-utils": "~0.14.0", | ||
"react-dom": "0.14.x" | ||
"react-dom": "0.14.x", | ||
"sinon": "^1.17.3" | ||
}, | ||
@@ -54,0 +55,0 @@ "pre-commit": [ |
@@ -61,3 +61,2 @@ # rc-upload | ||
|accept | string | | input accept attribute | | ||
|forceAjax | bool | | force to use ajax render. used for server render | | ||
|multiple | boolean | false | only support ie10+| | ||
@@ -64,0 +63,0 @@ |onStart | function| | start upload file | |
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
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
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
20202
0
0
450
9
102