Changing BaseURL for FileUpload component

UI Components for React
Post Reply
heindiez
Posts: 6
Joined: 18 Sep 2019, 10:51

25 Oct 2019, 04:29

Hi,

Im currently adding a FileUpload component into my system and I'm trying to figure out how to change the BaseURL when uploading the file.

I tried changing the baseURL in the onBeforeUpload, onBeforeSend handlers but I cant figure out since the documentation lacks properties to where it should be. Anyways, If someone has knowledge, Please do post it here.

Thanks!

heindiez
Posts: 6
Joined: 18 Sep 2019, 10:51

25 Oct 2019, 08:14

I found a way while searching through other forum topics on how to change baseURL for FileUpload component.

for anyone else wondering. Here is how It was changed.
you just need to specify your whole URL in the url parameter.

Code: Select all

<FileUpload mode="basic" name="fileUpload" 
       url={`${ADD YOUR BASE URL HERE}/upload`} 
       onBeforeSend={this.onUploadDocuments} 
       auto={true} chooseLabel="Upload"/>
if you need to add headers or authorization. Just add it in the onBeforeSend
handler event.xhr

Code: Select all

onUploadDocuments(event) {
       event.xhr.setRequestHeader('token', {ADD YOUR TOKEN HERE});
       event.xhr.setRequestHeader('authorization', {ADD YOUR AUTHORIZATION HERE});
 }
I hope this helps.

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest