Reputation:
I have some files on my disc which I would like to download. Is it possible to do in a similar way which I want to do it? I attach example but I didn't work.
ngOnInit() {
this.fetchPlugin()
}
fetchPlugin(){
console.log("Fetching...")
forkJoin(
this.httpClient.get('C:\\Users\\xxx\\Desktop\\file.js', {responseType: "blob"}),
this.httpClient.get('C:\\Users\\xxx\\file2.js', {responseType: "blob"}),
this.httpClient.get('C:\\Users\\xxx\\file3.js', {responseType: "blob"})
).subscribe((response) => {
console.log(response)
});
}
Upvotes: 2
Views: 2620
Reputation: 116
you can use nodejs or any backend language you are using to respond the file you require. In expressjs u can even use res.download('file_path',callback())
, Angular is used for client side manipulation.
Upvotes: 1
Reputation: 10179
The answer is: You can't!
The reason is, those Angular codes are simply Javascript codes which are executed on the client computer. For many reasons, the Javascript programming language is unable to, let's say, is not allowed to access the file system of the client computer.
Accessing the file system using Javascript is only possible with NodeJS - a javascript framework which allows you programming on the server-side using Javascript programming language.
Upvotes: 3