react-component / react-component/upload

Handling dynamic headers from transformFile

Open
#224 2 comments 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

Hi there!

We have a situation where we use rc-upload in the following manner:

  • User selects file on file system
  • We use transformFile to encrypt the contents of that file on the browser
  • The encryption generates additional metadata that we want to pass as headers
  • This metadata is not available until transformFile is completed.

It would be great if headers could also be a function that takes in the result of transformFile and returns the headers.

I tried to make a PR for this but it was not possible bc of permissions.

The changes to do this are pretty quick:
in AjaxUploader.tsx

change

headers: props.headers,

to

headers: typeof props.headers === 'function' ? props.headers(transformedFile) : props.headers,

and also update the README comment to me

|headers| object/function(blob) | {} | http headers to post, available in modern browsers. Can be a function that takes in the result of transformFile |

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 in src/AjaxUploader.jsx at the headers passed to the upload request, and review the transformFile flow described in the issue. Update the README headers entry alongside the behavior. Done means headers can be supplied as a function receiving the transformed file, while object headers continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.