【问题标题】:Upload a file from URL then send it from angular to springboot从 URL 上传文件,然后将其从 Angular 发送到 springboot
【发布时间】:2022-01-03 16:41:07
【问题描述】:

我正在寻找专门从 URL 上传文件的解决方案,我自己还没有找到解决方案。 对于上传,我已经有了以后应该做的工作。但最重要的是我有一个 url,我必须从那里上传一个音频文件到 spring 以后。

有人可以帮忙吗?

【问题讨论】:

  • 我需要知道是否可以在后台而不是在导航器上下载文件并将其存储在我们可以使其可供客户下载的路径中。

标签: angular url upload


【解决方案1】:

我终于通过http.get(url)从URL下载音频文件,然后我将bufferarray作为选项传递给请求,之后我使用此代码转换文件并将其上传到我的springboot目录:

 this.acapelaSRV.downloadAudioAsBlob(url).subscribe(
        data => {
          let blob = new Blob([data], { type: "audio/x-wav"});
          let namefile = this.utilitySRV.makerandom(12)+'_'+this.nomfichieraudio+'_'+this.client_connected.id+".wav";
          var file = new File([blob], namefile);
          this.uploadSRV.pushFileToStorage(file).subscribe(
            success => {
              console.log('File Saved to local');
              UploadDone = true;
            },
            error => {
              console.log(error);
              UploadDone = false;
            }
          )
          if(UploadDone){
            this.saveaudio({id: null, nom: this.nomfichieraudio, nom_storage: namefile, text: this.text_To_Speech, langue: this.selected_language, voix: this.selected_voice, id_client: this.client_connected.id})
          }
        },
        error =>{
          console.log(error);
        }
      )

【讨论】:

    猜你喜欢
    • 2021-04-18
    • 1970-01-01
    • 2019-12-31
    • 2021-03-24
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-19
    相关资源
    最近更新 更多