Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling dynamic headers from transformFile #224

Open
michaelfarrell76 opened this issue Jan 22, 2020 · 2 comments
Open

Handling dynamic headers from transformFile #224

michaelfarrell76 opened this issue Jan 22, 2020 · 2 comments

Comments

@michaelfarrell76
Copy link

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 |

@michaelfarrell76 michaelfarrell76 changed the title Handling dynamic headers Handling dynamic headers from transformFile Jan 22, 2020
@magicdawn
Copy link

special use can be implemented via customReuqest,
you can use transformedFile.headers & set to headers via customRequest

@michaelfarrell76
Copy link
Author

ya ended up doing it this way, had to do a lot of copy and paste but it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants