If you control the backend, the most reliable way to rename a file is by setting the Content-Disposition HTTP header. This tells the browser exactly what the filename should be before the download even starts. Custom name for blob URL - javascript - Stack Overflow
Download Report Use code with caution.
By default, browsers determine the name of a downloaded file using the URL or server headers. However, there are several ways to use or control the filename during the process. Depending on whether you are working in the browser or on a server like Node.js, your approach will vary from using simple HTML5 attributes to manipulating binary Blob data. 1. The Browser Method: Using the download Attribute javascript rename file after download