Skip to content
Advertisement

change file name in angular when download that by “Blob”

i want to download file from server in angular :

this code from service:

JavaScript

and this code for download that file in brwoser:

JavaScript

but i have a problem with that , when i downlaod file , file name is this [object Blob] but i want to download by orginal name for example if file is file1.jpg , when downloaded file name must be fil1.jpg not [object Blob] . how can i solve this problem ???

Advertisement

Answer

Because you have named the file by response(It is an object). You were almost achieved. Just a little change as following:

JavaScript

to

JavaScript

Then you will get the correct file name.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement