我不熟悉Javascript,有没有办法可以创建自己的文件名?会发生什么是打开一个新选项卡,文件名是Guid格式。
if (urlCreator && headers['content-type'] != 'application/octet-stream') {
// Fallback to $window.location method
try {
// Prepare a blob URL
// Use application/octet-stream when using $window.location to force download
var objectUrl = urlCreator.createObjectURL(blob);
$window.open(objectUrl);
success = true;
} catch (ex) {
//console.log("Download link method with $window.location failed with the following exception:");
//console.log(ex);
}
}
答案 0 :(得分:0)
您可以使用FileSaver.js:
var FileSaver = require('file-saver');
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "hello world.txt");