简体   繁体   English

Kendo UI编辑器上载和缩略图Url事件

[英]Kendo UI Editor Upload and Thumbnail Url event

I'm trying to set request headers of Kendo UI Editor's Upload Url and ThumbnailUrl for authorization. 我正在尝试设置Kendo UI编辑器的Upload Url和ThumbnailUrl的请求标头以进行授权。

 $(document).on("change", "input[name=file]", function (e) { $("#Template").data("kendoEditor").options.imageBrowser.transport.uploadUrl.beforeSend = function (xhr) { xhr.setRequestHeader("Authorization", GetToken()); }; }); 

I've tried this one. 我已经尝试过了 Anybody knows how to set it? 有人知道如何设置吗? Kendo UI Upload have its event for upload and on the back-end Editor is also using Kendo UI Upload. Kendo UI Upload具有要上传的事件,并且在后端编辑器上也使用Kendo UI Upload。 Help will be appreciated. 帮助将不胜感激。 Thanks 谢谢

I got an answer from telerik support. 我得到了telerik支持的答复。 There is no event for upload. 没有上载事件。 But we can bind it in execute event. 但是我们可以在执行事件中绑定它。 here is the code 这是代码

 function onExecute(e) { if (e.name == "insertimage") { setTimeout(function () { var imagebrowser = $("[data-role=imagebrowser]").data("kendoImageBrowser"); imagebrowser.upload.bind("upload", function (e) { var xhr = e.XMLHttpRequest; if (xhr) { xhr.addEventListener("readystatechange", function (e) { if (xhr.readyState === 1 /* OPENED */) { xhr.setRequestHeader("Authorization", GetToken()); } }); } }); }, 0); } } 

There isn't a way to set a header for the thumbnail request. 无法为缩略图请求设置标题。 So I've achieved this functionality by sending user id as a query string in Thumbnail request. 因此,通过在缩略图请求中将用户ID作为查询字符串发送来实现了此功能。

  thumbnailUrl: hostHeaderUrl + "api/ImageBrowser/Thumbnail?userId=" + currUserId 

Hopefully my answer will help. 希望我的回答会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM