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

3 posts, 1 answers
  1. Adam
    Adam avatar
    5 posts
    Member since:
    Mar 2015

    Posted 19 Jul Link to this post


    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. Adam
    Adam avatar
    5 posts
    Member since:
    Mar 2015

    Posted 19 Jul in reply to Adam Link to this post

    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

  3. Answer
    Dimiter Madjarov
    Dimiter Madjarov avatar
    2127 posts

    Posted 20 Jul Link to this post

    Hello Adam,

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

    Dimiter Madjarov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top