AngularJS 从服务器下载文件时如何更改文件名

How to change file name when download it from server in AngularJS

我在 AngularJS

中使用以下代码下载文件
 $scope.download = function (row) {
        var url = row.entity.downloadUrl;
        window.open(url, "_blank");
 };

url 是来自文件 serve.How 的图像,我可以 change/set 下载它时的文件名而不使用来自文件服务器的名称吗?

我不想使用任何插件,可以吗?

创建 a html 属性并将其用于 download 您的文件。

var file_path = 'row.entity.downloadUrl';
var a = document.createElement('A');
a.href = file_path;
a.download = 'you new file name';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);