react-component / react-component/upload
Handling dynamic headers from transformFile
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
transformFileto 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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