如何使用 Kendo 文件上传异步方法获得响应?

How to get response using Kendo file upload async method?

我正在使用 kendo 从客户端上传文件,加载时一切都按预期工作,但是这里我有一个与 url 有关的问题,当我们上传文件时我正在使用 url 在文件加载成功时的配置中,我收到了服务器的响应。

如何使用 kendo async saveUrl 方法从响应中提取数据?

main.html

<div class="form-group col-md-6">
    <div class="col-md-6">
        <label for="prcFileUploadField">File:</label>
    </div>
    <div class="col-md-6">
        <input name="file" type="file" kendo-upload="fileAttachment" k-upload="addMorePostParameters" k-success="onSuccess" k-error="onError" k-options="fileAttachmentOptions" k-select="onSelect" k-remove="onUploadRemove" />
    </div>
</div>

ctrl.js

angular.module('App').controller('PrcUploadCtrl',function($scope,$timeout,$rootScope,prcUploadConfig){
    'use strict';
    var fileData = [];
    $scope.fileAttachmentOptions = prcUploadConfig.fileAttachmentConfig;

    $scope.prcUploadGridOptions = prcUploadConfig.getPrcUploadDataGrid;
    prcUploadConfig.getPrcUploadDataGrid.dataSource='';

    $scope.onSelect = function (e) {
        fileData = e.files;
        var message = $.map(e.files, function(file) { return file.name; }).join(", ");
        console.log(message);
        console.log(JSON.stringify(fileData));
    };

    //if error 
    $scope.onError = function() {
        console.log("loggin error");
        $timeout(function () {
            var filesToBeRemoved = $scope.fileAttachment.wrapper.find('.k-file');
            $scope.fileAttachment._removeFileEntry(filesToBeRemoved);
        },5000);
    }
});

config.js

fileAttachmentConfig: {
  async: {
      saveUrl: 'app/upload/uploadAttch',
      removeUrl: 'remove',
      removeVerb: 'DELETE',
      autoUpload: false
  },
  template: '<span class=\'file-name-heading\'>Name:</span> <span>#=name#</span><button type=\'button\' class=\'k-upload-action\'></button>'
}

您始终可以从成功的请求中获得响应正文,如下所示:

$scope.onSuccess = function(e) {
    var response = e.response;
    //...
}