Hello,
I cannot find an example of the upload with credentials where I can pass an authorization token in the header of the request, some help would be appreciated.
https://www.telerik.com/kendo-react-ui/components/upload/credentials/
Thanks,
1 Answer, 1 is accepted
Hello, Daniela,
This prop is used to determine if these credentials will be sent:
https://www.telerik.com/kendo-react-ui/components/upload/api/UploadProps/#toc-withcredentials
To add specific information to the request the developer can use the saveHeaders and removeHeaders props. They are sent in kye - value pair format:
https://www.telerik.com/kendo-react-ui/components/upload/api/UploadProps/#toc-saveheaders
https://www.telerik.com/kendo-react-ui/components/upload/api/UploadProps/#toc-removeheaders
Also, the additional information can be passed using this approach:
https://www.telerik.com/kendo-react-ui/components/upload/credentials/#toc-attaching-additional-data-to-requests
Regards,
Stefan
Progress Telerik
Hello,
Thanks a lot for the response, do you probably know how can I add information in the body of the request?
Thanks,
Hello, Daniela,
Currently, these are the option to add specific information to the request.
Please share more details on which information and where has to be added. You can demonstrate the requirement on a standard request and we will advise how and if this can be added to the Upload request.
Hello,
Below is an example of an upload request of how I am supposed to upload the files, if you see I have to add a lot of info into the body. Thanks
If the developer has to add different custom information, we can also suggest using the savelUrl as a function where the developer has full control over the request. This will allow adding any required parameters and making the request:
https://stackblitz.com/edit/react-bvfjbb-bgahfr?file=app/main.jsx
Please have in mind that the example shows only a mock of a request as we do not have a public server that can accept a request.
Hello,
Sorry I did not understand that example, where exactly can I add the parameters to the body in your example?
thanks a lot.
Hello, Daniela,
The example is demonstrating how the developer can make the request themselves. This means the actual request to the API will be made by the developer with fetch, axios, or any other tool.
Also, our example with additional data, show how to pass extra parameters to the request:
https://stackblitz.com/edit/react-y5sixt?file=app/main.jsx
Hello,
Thaks for your response, do you know if I can change the name "files" to "file" in the payload of the upload?
Thank you
Hello, Daniela,
Currently, the name is fixed to `files`.
I can suggest updating the server API to expect `files` instead of `file`.
Hello,
Yes, I'm sure that there is no public API property that is available for changing the files field.
The only other option is the one offered on 29 Oct 2021 to use the saveURL as a function and make the request programmatically:
https://stackblitz.com/edit/react-bvfjbb-bgahfr?file=app/main.jsx
This will require the developer to make the request using their preferred method.