Javascript 如何在AngularJS中自动下载文件视频

Javascript 如何在AngularJS中自动下载文件视频,javascript,angularjs,Javascript,Angularjs,我尝试在运行函数下载时自动下载视频。 我正在尝试使用saveAs(fileSaver.js),但出现了错误 未能对“URL”执行“createObjectURL”:未找到任何函数 与提供的签名相符 任何人都可以帮忙 $scope.download = function(){ var fd = new FormData(); angular.forEach($scope.files, function(video){ fd.append('v

我尝试在运行函数下载时自动下载视频。 我正在尝试使用saveAs(fileSaver.js),但出现了错误

未能对“URL”执行“createObjectURL”:未找到任何函数 与提供的签名相符

任何人都可以帮忙

$scope.download = function(){
        var fd = new FormData();
        angular.forEach($scope.files, function(video){
            fd.append('video', video);
        });

        var request = $http({
            method : 'POST',
            url: xxxx + 'video/upload?start=' + $scope.start + '&end=' + $scope.end,
            data : fd,
            transformRequest:angular.identity,
            headers:{'Content-Type':undefined}
        });
        request.then(function(response){
            saveAs(response , 'video.mp4');
            $scope.isProcessing = false;
        }, function(error){
            $scope.isProcessing = false;
        });
    }
在服务侧I中,使用烧瓶将返回如下所示:

return send_file(app.root_path + '/' + app.config['UPLOAD_FOLDER'] + '/uploadV/dd.mp4', as_attachment=True)
如果使用的是,则需要使用
arraybuffer
响应类型创建blob:

$scope.download = function(){

    var fd = new FormData();
    angular.forEach($scope.files, function(video){
        fd.append('video', video);
    });

    $http({
        method: 'POST',
        url: xxxx + 'video/upload?start=' + $scope.start + '&end=' + $scope.end,
        data: fd,
        transformRequest: angular.identity,
        responseType: 'arraybuffer',
        transformResponse: function (data) {
            var video;
            if (data) {
                video = new Blob([data], {
                    type: 'video/mp4'
                });
            }
            return {
                response: video
            };
        },
    }).then(function(file){
        saveAs(file.response, 'video.mp4');
        $scope.isProcessing = false;
    }, function(error){
        $scope.isProcessing = false;
    });
};

我遵循你的密码,我有错误。网络::错误连接被中止。我已经在模块中添加了ngFileSaver。有没有其他方法上传你知道的视频@lin@HannahDelisa你确定你的API端点和方法
POST
是可访问的吗?>
xxxx+'视频/上传?start='+$scope.start+'&end='+$scope.end
?这是python代码中的问题。现在每个人都认为很好,只有部分saveAs(file.response,'video.mp4')。错误show TypeError:无法在新FileSaver上读取未定义的属性“type”。谢谢你的帮助@lindid你知道这个方法以外的其他方法吗?@HannahDelisa你能把这个答案标记为正确吗?(向上投票回答按钮附近的灰色挂钩)!谢谢