$ http.post()在文件上传文件导入后冻结Chrome浏览器

时间:2018-12-04 14:59:20

标签: javascript angularjs google-chrome http file-upload

我被卡住了,内存泄漏在哪里?

我正在尝试什么?

导入.xlsx(存储)后,我将在响应中再次获取它们(我也尝试在其他ele click事件上独立获取它们)。

问题:

在$ http.post(...)上传2个-3文件chrome浏览器冻结后(在FF中工作正常),我添加了代码示例。

谢谢!

/***** HTML *****
<input type="file" onchange="angular.element(this).scope().storeBulkUpdate(this)">
*****/

/***  Controller  */
var paginationCriteria = {
    pageNo: 1,
    size: 10
};

$scope.getAllStoreStores = function (_data, qParam) {
    storeSevice.getStore(_data, $httpParamSerializer(qParam)).success(function (data) {
        console.log(data)
    });
}

$scope.storeBulkUpdate = function (element) {
    var fileData = element.files[0];
    var formData = new FormData();
    formData.append('file', fileData);
    storeSevice.bulkUpdateStore(formData).success(function (data, status, headers, config) {
        $scope.getAllStore({}, paginationCriteria);
    });
};


/**Factory 'storeSevice' */
return {
    bulkUpdateStore: function (_postData) {
        url = '/upload'
        //Set Headers
        var header = {};
        var extendedHeader = AuthenticationService.createAuthorizationHeader(
            header,
            url,
            'POST',
            _postData
        );
        extendedHeader['ServiceName'] = 'uploadMTTForStore';
        extendedHeader['Content-Type'] = undefined;
        //Headers End
        return $http.post(url, _postData, {
            withCredentials: false,
            headers: extendedHeader,
            transformRequest: angular.identity
        });
    },

    getStore: function (_postData, $parameters) {
        url = '/getStore?' + $parameters;
        var header = {};
        var extendedHeader = AuthenticationService.createAuthorizationHeader(
            header,
            url,
            'POST'
        );
        extendedHeader['ServiceName'] = 'storeFetch';

        //browser feerze
        return $http.post(url, $postData, {
            headers: extendedHeader
        });
    },

    otherMethods: "etc......."
}

0 个答案:

没有答案