react-component / react-component/upload

Parsed File shape is incorrect on certain platforms

Open
#333 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
804
Forks
323
Avg merge
12m
Merged PRs (30d)
1

Description

After debugging a cordova instance of a web app, we ran into an issue with the file uploader, we found the error to be in the AjaxUploader.tsx

Here is the patch that we had to apply to fix the issue:
diff --git a/node_modules/rc-upload/es/AjaxUploader.js b/node_modules/rc-upload/es/AjaxUploader.js
index 34509ce..2d5a577 100644
--- a/node_modules/rc-upload/es/AjaxUploader.js
+++ b/node_modules/rc-upload/es/AjaxUploader.js
@@ -219,13 +219,15 @@ var AjaxUploader = /*#__PURE__*/function (_Component) {
                 // Not sure if this will work since no related test case works with it
                 (_typeof(transformedFile) === 'object' || typeof transformedFile === 'string') && transformedFile ? transformedFile : file;
 
-                if (parsedData instanceof File) {
-                  parsedFile = parsedData;
-                } else {
-                  parsedFile = new File([parsedData], file.name, {
-                    type: file.type
-                  });
-                }
+                parsedFile = parsedData;
+
+                // if (parsedData instanceof File) {
+                //   parsedFile = parsedData;
+                // } else {
+                //   parsedFile = new File([parsedData], file.name, {
+                //     type: file.type
+                //   });
+                // }
 
                 mergedParsedFile = parsedFile;
                 mergedParsedFile.uid = file.uid;

Screenshots

Here is the debug point that triggered the parsed file change:

image

The mergedParsedFile's name becomes a [File] and the reset of the object is malformated:

image

Setup

antd: v4.16.2
Platform: Android 8.1
Cordova: v10
Cordova Android: v9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/AjaxUploader.tsx and inspect how parsedData becomes parsedFile and mergedParsedFile. Compare that flow with the supplied patch, then reproduce or investigate it on the listed Android/Cordova setup; done means the uploader preserves the parsed file shape and metadata on affected platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.