Missing options for uploading

4 posts, 1 answers
  1. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 20 Sep 2014 Link to this post

    In Editor and File/Image browser you can specify custom function to get data from server, create dir, remove dir, navigate...
    You can also send additional data ... because you have configurations for:
    • imageBrowser.transport.read 
    • imageBrowser.transport.read.contentType 
    • imageBrowser.transport.read.data 
    • ...

    But for upload there is only uploadUrl available. The browser expect that result from server is {"size":38020,"name":"logo_30.jpg","type":"f"} for example, but my server can not get response like this, but {"Something": ..., "Data": {"size":38020,"name":"logo_30.jpg","type":"f"}, "Additional": "value"}

    I really like options that you have with read, create dir, remove dir, navigate:

    imageBrowser.transport.create = function(o)
            {          
                $.post("url", params, function(response){o.success(response.Data)});
            };

    Is it possible to achieve this for upload? Or at least how can tell editor or stand alone Image/File Browser that result are in response.Data not just in response?

  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 23 Sep 2014 Link to this post

    Hi Matjaz,

    Unfortunately, the expected response from the server cannot be configured in this case. Sorry about that.

    You can submit a feature request at

    http://kendoui-feedback.telerik.com/

    Regards,
    Dimo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Matjaz
    Matjaz avatar
    94 posts
    Member since:
    Jun 2014

    Posted 07 Oct 2014 Link to this post

    I can not change the way data is responded from server. Is there any other way?
    Maybe to override some method ...
  5. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 09 Oct 2014 Link to this post

    Hello Matjaz,

    Yes, you can edit the ImageBrowser/FileBrowser source code, or override the _fileUpload method in kendo.filebrowser.js. What needs to be changed is the success event handler of the Upload widget, which handles the server response:

    // .......
     
    that.upload.one("success", function(e) {
        model.set(fileNameField, e.response[that._getFieldName(fileNameField)]);
        model.set(sizeField, e.response[that._getFieldName(sizeField)]);
        that._tiles = that.listView.items().filter("[" + kendo.attr("type") + "=f]");
    });
     
    // ......

    In order to override the FileBrowser prototype, you need to execute the following code before initializing any Editors.

    kendo.ui.FileBrowser.prototype._fileUpload = function (e) {
       // ...
    };


    Please keep in mind that editing or overriding the Kendo UI source falls outside the scope of our support service. In case you need further assistance with the discussed custom implementation or any resulting side effects, limitations, etc, you can refer to our partner network.

    http://partners.telerik.com/find-a-partner

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready