Angular 6-从磁盘获取文件 [英] Angular 6 - get file from disk

查看:45
本文介绍了Angular 6-从磁盘获取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的光盘上有一些文件要下载.是否可以用与我想做的类似的方式来做?我附上示例,但是我没有用.

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)

      });
    }

推荐答案

答案是:不能!

原因是,这些Angular代码只是在客户端计算机上执行的Javascript代码.出于多种原因,例如,不允许Javascript编程语言访问客户端计算机的文件系统.

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.

只能使用NodeJS(使用Javascript框架,它允许您使用Javascript编程语言在服务器端进行编程)来使用Javascript访问文件系统.

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.

这篇关于Angular 6-从磁盘获取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆