rc-upload
Advanced tools
Comparing version 4.1.0 to 4.2.0-alpha.0
import React, { Component } from 'react'; | ||
import type { UploadProps, RcFile, BeforeUploadFileType } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
interface ParsedFileInfo { | ||
@@ -7,3 +7,3 @@ origin: RcFile; | ||
data: object; | ||
parsedFile: Exclude<BeforeUploadFileType, boolean>; | ||
parsedFile: RcFile; | ||
} | ||
@@ -10,0 +10,0 @@ declare class AjaxUploader extends Component<UploadProps> { |
@@ -136,3 +136,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, fileList) { | ||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedFile; | ||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedData, parsedFile, mergedParsedFile; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -219,18 +219,24 @@ while (1) { | ||
case 30: | ||
parsedFile = // string type is from legacy `transformFile`. | ||
parsedData = // string type is from legacy `transformFile`. | ||
// Not sure if this will work since no related test case works with it | ||
(_typeof(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file; // Used for `request.ts` get form data name | ||
(_typeof(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file; | ||
if (_typeof(parsedFile) === 'object' && !parsedFile.name) { | ||
parsedFile.name = file.name; | ||
if (parsedData instanceof File) { | ||
parsedFile = parsedData; | ||
} else { | ||
parsedFile = new File([parsedData], file.name, { | ||
type: file.type | ||
}); | ||
} | ||
mergedParsedFile = parsedFile; | ||
mergedParsedFile.uid = file.uid; | ||
return _context.abrupt("return", { | ||
origin: file, | ||
data: mergedData, | ||
parsedFile: parsedFile, | ||
parsedFile: mergedParsedFile, | ||
action: mergedAction | ||
}); | ||
case 33: | ||
case 35: | ||
case "end": | ||
@@ -299,7 +305,7 @@ return _context.stop(); | ||
var onProgress = _this2.props.onProgress; | ||
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, origin); | ||
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, parsedFile); | ||
}, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
var onSuccess = _this2.props.onSuccess; | ||
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(ret, origin, xhr); | ||
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(ret, parsedFile, xhr); | ||
delete _this2.reqs[uid]; | ||
@@ -309,3 +315,3 @@ }, | ||
var onError = _this2.props.onError; | ||
onError === null || onError === void 0 ? void 0 : onError(err, ret, origin); | ||
onError === null || onError === void 0 ? void 0 : onError(err, ret, parsedFile); | ||
delete _this2.reqs[uid]; | ||
@@ -312,0 +318,0 @@ } |
import React, { Component } from 'react'; | ||
import type { UploadProps, RcFile, BeforeUploadFileType } from './interface'; | ||
import type { UploadProps, RcFile } from './interface'; | ||
interface ParsedFileInfo { | ||
@@ -7,3 +7,3 @@ origin: RcFile; | ||
data: object; | ||
parsedFile: Exclude<BeforeUploadFileType, boolean>; | ||
parsedFile: RcFile; | ||
} | ||
@@ -10,0 +10,0 @@ declare class AjaxUploader extends Component<UploadProps> { |
@@ -161,3 +161,3 @@ "use strict"; | ||
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(file, fileList) { | ||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedFile; | ||
var beforeUpload, transformedFile, action, mergedAction, data, mergedData, parsedData, parsedFile, mergedParsedFile; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
@@ -244,18 +244,24 @@ while (1) { | ||
case 30: | ||
parsedFile = // string type is from legacy `transformFile`. | ||
parsedData = // string type is from legacy `transformFile`. | ||
// Not sure if this will work since no related test case works with it | ||
((0, _typeof2.default)(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file; // Used for `request.ts` get form data name | ||
((0, _typeof2.default)(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file; | ||
if ((0, _typeof2.default)(parsedFile) === 'object' && !parsedFile.name) { | ||
parsedFile.name = file.name; | ||
if (parsedData instanceof File) { | ||
parsedFile = parsedData; | ||
} else { | ||
parsedFile = new File([parsedData], file.name, { | ||
type: file.type | ||
}); | ||
} | ||
mergedParsedFile = parsedFile; | ||
mergedParsedFile.uid = file.uid; | ||
return _context.abrupt("return", { | ||
origin: file, | ||
data: mergedData, | ||
parsedFile: parsedFile, | ||
parsedFile: mergedParsedFile, | ||
action: mergedAction | ||
}); | ||
case 33: | ||
case 35: | ||
case "end": | ||
@@ -324,7 +330,7 @@ return _context.stop(); | ||
var onProgress = _this2.props.onProgress; | ||
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, origin); | ||
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, parsedFile); | ||
}, | ||
onSuccess: function onSuccess(ret, xhr) { | ||
var onSuccess = _this2.props.onSuccess; | ||
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(ret, origin, xhr); | ||
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(ret, parsedFile, xhr); | ||
delete _this2.reqs[uid]; | ||
@@ -334,3 +340,3 @@ }, | ||
var onError = _this2.props.onError; | ||
onError === null || onError === void 0 ? void 0 : onError(err, ret, origin); | ||
onError === null || onError === void 0 ? void 0 : onError(err, ret, parsedFile); | ||
delete _this2.reqs[uid]; | ||
@@ -337,0 +343,0 @@ } |
{ | ||
"name": "rc-upload", | ||
"version": "4.1.0", | ||
"version": "4.2.0-alpha.0", | ||
"description": "upload ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
61013
1480
1