有什么方法可以使用拖动n拖放以角度上传.ply,.stl,.obj文件?

时间:2019-02-24 16:10:16

标签: javascript angular typescript

在这里,我的问题是我要上传.ply,.stl,.obj表示成角度的3d模型。目前,我正在使用ng2-upload插件进行拖放操作,该插件不支持这些文件类型。无论何时上传文件,都不会获得mime类型。

下面是我的代码:

 imga = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/256/Button-Upload-icon.png";



       public uploader:FileUploader = new FileUploader({url: URL});
          public hasBaseDropZoneOver:boolean = false;
          public hasAnotherDropZoneOver:boolean = false;
          public selectedFilesArray = [];
          private selectedFile;

        public selectFile(e: any): void {
        var target = e.target || e.srcElement || e.currentTarget;
        var value = target.innerHTML;
        this.selectedFile = value;
        this.selectAll = true;
        this.selectedFilesArray = [];
        this.selectedFilesArray.push(this.selectedFile);

      }
      public fileOverBase(e: any): void {
        this.hasBaseDropZoneOver = e;
      }

        public selectAllFiles(e: any): void {

        this.selectedFilesArray = [];
        if (e.target.checked) {

          this.selectAll = true;

          for (var item in this.uploader.queue) {
            this.selectedFilesArray.push(this.uploader.queue[item].file.name);
          }




        }


      }

我正在尝试使用ng2-file-upload上传各种文件,并且在这里我可以上传png,jpg等所有文件类型(.ply文件除外),那么如何上传具有该扩展名的文件?< / p>

下面是我的代码:

  imga = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/256/Button-Upload-icon.png";

  public uploader:FileUploader = new FileUploader({url: URL});
  public hasBaseDropZoneOver:boolean = false;
  public hasAnotherDropZoneOver:boolean = false;
  public selectedFilesArray = [];
  private selectedFile;



    public selectFile(e: any): void {
    var target = e.target || e.srcElement || e.currentTarget;
    var value = target.innerHTML;
    this.selectedFile = value;
    this.selectAll = true;
    this.selectedFilesArray = [];
    this.selectedFilesArray.push(this.selectedFile);

  }
  public fileOverBase(e: any): void {
    this.hasBaseDropZoneOver = e;
  }

    public selectAllFiles(e: any): void {

    this.selectedFilesArray = [];
    if (e.target.checked) {

      this.selectAll = true;

      for (var item in this.uploader.queue) {
        this.selectedFilesArray.push(this.uploader.queue[item].file.name);
      }




    }


  }

下面是我的stackblitz网址:https://stackblitz.com/edit/angular-r6cbrj

1 个答案:

答案 0 :(得分:0)

ply不是ng2-file-upload识别的MIME类型。您可以在以下源代码中找到所有受支持的MIME类型:

https://github.com/valor-software/ng2-file-upload/blob/development/src/file-upload/file-type.class.ts

如您所见,未列出的文件扩展名的内容类型设置为application