This is a migrated thread and some comments may be shown as answers.

How to call a different removeUrl for each file on remove?

2 Answers 265 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 19 Jul 2016, 07:12 PM

Hello, 

The endpoints that I'm using to save & remove files with the uploader is implemented as a restful service. The endpoints look something like this: 

POST : api/resource/{resourceId}/attachments 

DELETE api/resource/{resourceId}/attachments/{attachmentId}

The post works no problem. I'm having trouble with the DELETE however because I need to the URL called for each file to include the id of the attachment being deleted.

My config looks like this at the moment:

<input name="files" type="file" kendo-upload k-files="wiz.attachments" k-async="{withCredentials : false,saveUrl : attachmentUrl, removeUrl : attachmentUrl, removeVerb : "DELETE", autoUpload : true}" k-select="onSelect" k-multiple="true"/>

Is it possible for me to change the removeUrl based on the file selected? 

 

Thanks for your help

2 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 19 Jul 2016, 08:28 PM

for better or worse, what I did for this was to create a function to attach to the remove event, then override the removeUrl when that was called : 

 

onRemove = function(e)  {
e.sender.options.async.removeUrl = "api/resource/{resourceId}/attachments/" + e.files[0].id;
};

 

Works well, but perhaps there is a cleaner way

0
Accepted
Dimiter Madjarov
Telerik team
answered on 20 Jul 2016, 06:28 AM

Hello Adam,

This is the recommended way to achieve the task. You could also use the select event handler if needed.

Regards,
Dimiter Madjarov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Upload
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or