Separate [saveUrl] per selected file

1 Answer 52 Views
Upload
Yuriy Rogach
Top achievements
Rank 1
Iron
Yuriy Rogach asked on 13 Oct 2022, 12:59 PM

Is it possible to customize [saveUrl] per selected file in kendo-upload component?

I would like to POST a file to the https://my.api.com/files in one scenario and PUT a file to the https://my.api.com/files/fileId in another one.

1 Answer, 1 is accepted

Sort by
0
Accepted
Yuriy Rogach
Top achievements
Rank 1
Iron
answered on 13 Oct 2022, 03:36 PM

If someone else is interested, it is easily achieved by setting [saveUrl] and [saveMethod] in uploadEventHandler


if (event.files[0].name === "somecondition"){
	this.attachmentsComponent.saveUrl =`https://my.api.com/files/fileId`;
	this.attachmentsComponent.saveMethod = 'PUT';
} else {
	this.attachmentsComponent.saveUrl = `https://my.api.com/files`;
	this.attachmentsComponent.saveMethod = 'POST';
}

Tags
Upload
Asked by
Yuriy Rogach
Top achievements
Rank 1
Iron
Answers by
Yuriy Rogach
Top achievements
Rank 1
Iron
Share this question
or