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

Missing options for uploading

3 Answers 37 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Matjaz
Top achievements
Rank 1
Matjaz asked on 20 Sep 2014, 11:32 AM
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?

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 23 Sep 2014, 03:33 PM
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!
 
0
Matjaz
Top achievements
Rank 1
answered on 07 Oct 2014, 06:33 PM
I can not change the way data is responded from server. Is there any other way?
Maybe to override some method ...
0
Accepted
Dimo
Telerik team
answered on 09 Oct 2014, 11:07 AM
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!
Tags
Editor
Asked by
Matjaz
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Matjaz
Top achievements
Rank 1
Share this question
or