I'm not that familiar with Javascript, is there a way that I can create my own filename? What happens is it opens a new tab and the filename is in Guid Format.
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);
}
}
You can use FileSaver.js for this:
var FileSaver = require('file-saver');
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "hello world.txt");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With